home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / actions.cpp < prev    next >
C/C++ Source or Header  |  1996-03-07  |  139KB  |  6,177 lines

  1. /******************************************************************************
  2. *******************************************************************************
  3.  
  4. Player action routines...
  5.  
  6. ******************************************************************************
  7. *****************************************************************************/
  8.  
  9. #include "global.h"
  10. #include "3deng.h"
  11. #include "data.h"
  12. #include "ball.dta"
  13.  
  14. #include "defines.h"
  15. #include "externs.h"
  16. #include "audio.h"                            // Kev's audio calls.
  17. #include "front.h"
  18. #include "eurofrnt\euro_int.h"
  19.  
  20. extern team_info game_data[];
  21. extern setup_info setup;
  22. extern stad_info stadlist[];
  23. extern match_data match_info;
  24.  
  25. extern short get_there_time(int p_num,float x,float y);
  26.  
  27. /******************************************************************************
  28. *****************************************************************************/
  29.  
  30. // Converts Statistical speed to actual game speed (takes possession of ball into account!)...
  31.  
  32. float full_spd(match_player *p)
  33. {
  34.     float a;
  35.  
  36.     if (p->int_move==I_CELEB)
  37.         a=MC_CELEB_SPD;
  38.     else
  39.         a=((float)pitch_len)/((18.-(((float)(p->tm_rate)/64)*4))*20);
  40.  
  41.     return(a);
  42. }
  43.  
  44. /******************************************************************************
  45. *****************************************************************************/
  46.  
  47. // Converts Statistical speed to actual game speed (takes possession of ball into account!)...
  48.  
  49. float actual_spd(match_player *p)
  50. {
  51.     float a;
  52.  
  53.     if (p->int_move==I_CELEB)
  54.         a=MC_CELEB_SPD;
  55.     else
  56.         if (p->int_move==I_INTERCEPT && p->int_cnt)
  57. // Chasing Ball (must run)...
  58.             a=((float)pitch_len)/((18.-(((float)(p->tm_rate)/64)*4))*20);
  59.         else
  60.             if (p->go_step)
  61. // Side stepping...
  62.                 a=((float)pitch_len)/((24.-(((float)(p->tm_rate)/64)*4))*20);
  63.             else
  64.                 if (ball_poss==p->tm_player)
  65. // Avg runs pitch length in 14 secs.
  66. // Top run in 10 secs.
  67.                 {
  68.                     if (ball_in_hands && (p->tm_player==KP_A || p->tm_player==KP_B))
  69. // Keeper with ball in his hands...(slow)
  70.                         a=((float)pitch_len)/((28.-(((float)(p->tm_rate)/64)*4))*20);
  71.                     else
  72.                         a=((float)pitch_len)/((20.-(((float)(p->tm_rate)/64)*4))*20);
  73.                 }
  74.                 else
  75. // Avg runs pitch length in 16 secs.
  76. // Top run in 12 secs.
  77.                     if (user_controlled && burst_timer[user_controlled-1]>0)
  78.                         a=((float)pitch_len)/(((18.-(float)burst_timer[user_controlled-1]/5)-(((float)(p->tm_rate)/64)*4))*20);
  79.                     else
  80.                         a=((float)pitch_len)/((18.-(((float)(p->tm_rate)/64)*4))*20);
  81.  
  82.     return(a);
  83. }
  84.  
  85. /******************************************************************************
  86. *****************************************************************************/
  87.  
  88. void init_officials()
  89. {
  90.     refs[0].x=cntspot_x;
  91.     refs[1].x=cntspot_x;
  92.     refs[2].x=cntspot_x;
  93.     refs[0].goto_x=cntspot_x;
  94.     refs[1].goto_x=cntspot_x;
  95.     refs[2].goto_x=cntspot_x;
  96.  
  97.     refs[0].y=cntspot_y;
  98.     refs[0].goto_y=cntspot_y;
  99.     refs[1].y=-(prat*2);
  100.     refs[1].goto_y=-(prat*2);
  101.     refs[2].y=pitch_wid+(prat*2);
  102.     refs[2].goto_y=pitch_wid+(prat*2);
  103.     refs[0].z=0;
  104.     refs[1].z=0;
  105.     refs[2].z=0;
  106.     refs[0].dir_x=0;
  107.     refs[1].dir_x=0;
  108.     refs[2].dir_x=0;
  109.     refs[0].dir_y=1;
  110.     refs[1].dir_y=1;
  111.     refs[2].dir_y=-1;
  112.     refs[0].anim=MC_PLEAD;
  113.     refs[1].anim=MC_STAND;
  114.     refs[2].anim=MC_STAND;
  115.     refs[0].fstep=MC_PLEAD_FS;
  116.     refs[1].fstep=MC_STAND_FS;
  117.     refs[2].fstep=MC_STAND_FS;
  118.     refs[0].frm=0.6;
  119.     refs[1].frm=0;
  120.     refs[2].frm=0;
  121.     refs[0].act=0;
  122.     refs[1].act=0;
  123.     refs[2].act=0;
  124.  
  125.     refs[0].target=0;
  126.     refs[1].target=0;
  127.     refs[2].target=0;
  128.  
  129.     refs[0].go=0;
  130.     refs[1].go=0;
  131.     refs[2].go=0;
  132.  
  133.     refs[0].newanim=TRUE;
  134.     refs[1].newanim=TRUE;
  135.     refs[2].newanim=TRUE;
  136.  
  137. }
  138.  
  139. /******************************************************************************
  140. *****************************************************************************/
  141.  
  142. void check_practice()
  143. {
  144.     if (match_info.CompetitionType==PRACTICE)
  145.         practice=1;
  146.     else
  147.         practice=0;
  148.  
  149.     switch(practice)
  150.     {
  151.         case(0):
  152.             team_a_on=TRUE;
  153.             team_b_on=TRUE;
  154.             break;
  155.  
  156.         case(1):
  157.             team_a_on=TRUE;
  158.             team_b_on=FALSE;
  159.             break;
  160.  
  161.         case(-1):
  162.             team_a_on=FALSE;
  163.             team_b_on=TRUE;
  164.             break;
  165.     }
  166. }
  167.  
  168. /******************************************************************************
  169. *****************************************************************************/
  170.  
  171. void init_team()
  172. {
  173.     int i;
  174.  
  175.     check_practice();
  176.  
  177.     for (i=1; i<=22; i++)
  178.     {
  179.         init_player_stats(i);
  180.         if (i==2)
  181.         {
  182.             teams[i-1].tm_rate=120;
  183.             teams[i-1].tm_pow=120;
  184.             teams[i-1].tm_cont=120;
  185.             teams[i-1].tm_flair=120;
  186.             teams[i-1].tm_vis=120;
  187.             teams[i-1].tm_ac=120;
  188.             teams[i-1].tm_stam=120;
  189.             teams[i-1].tm_disc=120;
  190.         }
  191.     }
  192.  
  193.     for (i=0; i<(players/2); i++)
  194.     {
  195.         if (team_a_on)
  196.         {
  197.             teams[i].tm_player=i+1;
  198.             teams[i].tm_x=cntspot_x-prat*2;
  199.             teams[i].tm_y=(cntspot_y+10*24)-(i*24);
  200.             teams[i].tm_z=0;
  201.  
  202.             teams[i].tm_xdis=1;
  203.             teams[i].tm_ydis=0;
  204.             teams[i].tm_zdis=0;
  205.  
  206.             teams[i].mface=0;
  207.             teams[i].tm_dist=50;
  208.             teams[i].tm_pos=1;
  209.             teams[i].tm_limbo=0;
  210.  
  211.             teams[i].guy_on=TRUE;
  212.  
  213.             teams[i].control=0;
  214.             teams[i].tm_srng=0;
  215.             teams[i].tm_off=0;
  216.             teams[i].tm_stopped=0;
  217.             teams[i].tm_trap=0;
  218.             teams[i].special=0;
  219.             teams[i].tm_strike=0;
  220.             teams[i].tm_stime=0;
  221.             teams[i].tm_ftime=0;
  222.             teams[i].ball_state=0;
  223.             teams[i].tm_fpass_type=0;
  224.             teams[i].tm_fpass_to=0;
  225.             teams[i].draw_me=TRUE;
  226.  
  227.             teams[i].shirt=i+1;
  228.  
  229.             teams[i].tm_book=0;
  230.             teams[i].tm_fouls=0;
  231.             teams[i].tm_tacks=0;
  232.             teams[i].tm_twon=0;
  233.             teams[i].tm_shots=0;
  234.             teams[i].tm_saved=0;
  235.             teams[i].tm_goals=0;
  236.             teams[i].tm_pass=0;
  237.             teams[i].tm_pwon=0;
  238.             teams[i].tm_inj=0;
  239.             teams[i].tm_posst=0;
  240.             teams[i].tm_work=0;
  241.             teams[i].tm_kpsaves=0;
  242.             teams[i].tm_ogs=0;
  243.             teams[i].tm_time=0;
  244.             
  245.             teams[i].turn_dir=0;
  246.             teams[i].face_dir=0;
  247.             teams[i].dir_mode=0;
  248.             teams[i].tm_frm=0;
  249.             teams[i].tm_fstep=MC_STAND_FS;            // For intitialisation purposes.
  250.             teams[i].tm_anim=MC_STAND;
  251.             teams[i].tm_hcol=0;
  252.             teams[i].tm_htype=0;
  253.             teams[i].tm_mcspd=(float)(teams[i].tm_flair+teams[i].tm_rate)/128;
  254.             teams[i].ls_anim=0;
  255.             teams[i].ls_frm=0;
  256.             teams[i].contact=-1;
  257.             teams[i].tm_newanim=1;
  258.             teams[i].tm_barge=0;
  259.  
  260.             teams[i].tm_act=0;
  261.             teams[i].tm_poss=0;
  262.             teams[i].tm_wall=0;
  263.             teams[i].tm_leave=0;
  264.             teams[i].tm_mark=0;
  265.             teams[i].go_dist=0;
  266.             teams[i].go_cnt=0;
  267.             teams[i].go_txdis=0;
  268.             teams[i].go_tydis=0;
  269.             teams[i].go_tx=teams[i].tm_x;
  270.             teams[i].go_ty=teams[i].tm_y;
  271.             teams[i].go_xoff=0;
  272.             teams[i].go_yoff=0;
  273.             teams[i].tm_jump=PLAYER_HEIGHT+6+(teams[i].tm_pow/10);
  274.             teams[i].go_stop=0;
  275.             teams[i].go_step=0;
  276.             teams[i].tm_notme=0;
  277.  
  278.             teams[i].int_move=0;
  279.             teams[i].int_cnt=0;
  280.             teams[i].mess_num=0;
  281.             teams[i].mess_cnt=0;
  282.             teams[i].tm_comm=0;
  283.             teams[i].tm_ccnt=0;
  284.         }
  285.         else
  286.             teams[i].guy_on=FALSE;
  287.     }
  288.     for (i=11; i<players; i++)
  289.     {
  290.         if (team_b_on || i==11)
  291. //        if (team_b_on)
  292.         {
  293.  
  294.             teams[i].tm_player=i+1;
  295.             teams[i].tm_x=cntspot_x+prat*2;
  296.             teams[i].tm_y=(cntspot_y+10*24)-((i-11)*24);
  297.             teams[i].tm_z=0;
  298.  
  299.             teams[i].tm_xdis=-1;
  300.             teams[i].tm_ydis=0;
  301.             teams[i].tm_zdis=0;
  302.  
  303.             teams[i].mface=0;
  304.             teams[i].tm_dist=50;
  305.             teams[i].tm_pos=1;
  306.             teams[i].tm_limbo=0;
  307.  
  308.             teams[i].guy_on=TRUE;
  309.  
  310.             teams[i].control=0;
  311.             teams[i].tm_srng=0;
  312.             teams[i].tm_off=0;
  313.             teams[i].tm_stopped=0;
  314.             teams[i].tm_trap=0;
  315.             teams[i].special=0;
  316.             teams[i].tm_strike=0;
  317.             teams[i].tm_stime=0;
  318.             teams[i].tm_ftime=0;
  319.             teams[i].ball_state=0;
  320.             teams[i].tm_fpass_type=0;
  321.             teams[i].tm_fpass_to=0;
  322.             teams[i].draw_me=TRUE;
  323.  
  324.             teams[i].shirt=i-10;
  325.  
  326.             teams[i].tm_book=0;
  327.             teams[i].tm_fouls=0;
  328.             teams[i].tm_tacks=0;
  329.             teams[i].tm_twon=0;
  330.             teams[i].tm_shots=0;
  331.             teams[i].tm_saved=0;
  332.             teams[i].tm_goals=0;
  333.             teams[i].tm_pass=0;
  334.             teams[i].tm_pwon=0;
  335.             teams[i].tm_inj=0;
  336.             teams[i].tm_posst=0;
  337.             
  338.             teams[i].turn_dir=0;
  339.             teams[i].face_dir=0;
  340.             teams[i].dir_mode=0;
  341.             teams[i].tm_frm=0;
  342.             teams[i].tm_fstep=MC_STAND_FS;            // For intitialisation purposes.
  343.             teams[i].tm_anim=MC_STAND;
  344.             teams[i].tm_hcol=0;
  345.             teams[i].tm_htype=0;
  346.             teams[i].tm_mcspd=(float)(teams[i].tm_flair+teams[i].tm_rate)/128;
  347.             teams[i].ls_anim=0;
  348.             teams[i].ls_frm=0;
  349.             teams[i].contact=-1;
  350.             teams[i].tm_newanim=1;
  351.             teams[i].tm_barge=0;
  352.  
  353.             teams[i].tm_act=0;
  354.             teams[i].tm_poss=0;
  355.             teams[i].tm_wall=0;
  356.             teams[i].tm_leave=0;
  357.             teams[i].tm_mark=0;
  358.             teams[i].go_dist=0;
  359.             teams[i].go_cnt=0;
  360.             teams[i].go_txdis=0;
  361.             teams[i].go_tydis=0;
  362.             teams[i].go_tx=teams[i].tm_x;
  363.             teams[i].go_ty=teams[i].tm_y;
  364.             teams[i].go_xoff=0;
  365.             teams[i].go_yoff=0;
  366.             teams[i].tm_jump=PLAYER_HEIGHT+6+(teams[i].tm_pow/10);
  367.             teams[i].go_stop=0;
  368.             teams[i].go_step=0;
  369.             teams[i].tm_notme=0;
  370.  
  371.             teams[i].int_move=0;
  372.             teams[i].int_cnt=0;
  373.             teams[i].mess_num=0;
  374.             teams[i].mess_cnt=0;
  375.             teams[i].tm_comm=0;
  376.             teams[i].tm_ccnt=0;
  377.  
  378.         }
  379.         else
  380.             teams[i].guy_on=FALSE;
  381.     }
  382.     reset_all_ideas();
  383.     interceptor_a=0;
  384.     interceptor_b=0;
  385. }
  386.  
  387. /******************************************************************************
  388. *****************************************************************************/
  389.  
  390. void taker_pass_f(float xp,float yp)
  391. {
  392.     short t;
  393.     float dif,x,y,d,nx,ny;
  394.  
  395.     t=(setp_taker<12 ? 10:21);    // team-mates!
  396.     pass_type=0;
  397.  
  398.     for (short i=t; i>t-11; i--)
  399.     {
  400.         if (setp_taker!=i+1)
  401. // Not man on ball!
  402.         {
  403.             if ((teams[i].tm_act<=TURN_ACT) && (teams[i].guy_on>0))
  404. // Not Busy!
  405.             {
  406.                 x=teams[i].tm_x-ballx;
  407.                 y=teams[i].tm_y-bally;
  408.                 d=calc_dist(x,y);
  409.  
  410.                 dif=((x*xp)+(y*yp))/d;
  411.                 if (dif>FACING_ANGLE)
  412.                 {
  413.                     pass_type=in_kicking_range(&teams[setp_taker-1],x,y);
  414.                 }
  415.  
  416.                 if (pass_type)
  417.                 {
  418.                     make_pass(&teams[setp_taker-1],i+1,FALSE);
  419.                     ready_set_kick();
  420.                     break;
  421.                 }
  422.             }
  423.         }
  424.     }
  425.  
  426.     if (!pass_type)
  427.     {
  428.         setp_kick_x=xp;
  429.         setp_kick_y=yp;
  430.         must_pass=10;
  431.         nx=(xp*teams[setp_taker-1].tm_xdis)+(yp*teams[setp_taker-1].tm_ydis);
  432.         ny=(yp*teams[setp_taker-1].tm_xdis)-(xp*teams[setp_taker-1].tm_ydis);
  433.         pass_type=(1+get_dir(nx,ny));
  434.         make_pass(&teams[setp_taker-1],0,FALSE);
  435.         ready_set_kick();
  436.     }
  437. }
  438.  
  439. /******************************************************************************
  440. *****************************************************************************/
  441.  
  442. void taker_pass_h(float xp,float yp)
  443. {
  444.     chip_pass=TRUE;
  445.     short t;
  446.     float dif,x,y,d,nx,ny;
  447.  
  448.     t=(setp_taker<12 ? 10:21);    // team-mates!
  449.     pass_type=0;
  450.  
  451.     for (short i=t; i>t-11; i--)
  452.     {
  453.         if (setp_taker!=i+1)
  454. // Not man on ball!
  455.         {
  456.             if ((teams[i].tm_act<=TURN_ACT) && (teams[i].guy_on>0))
  457. // Not Busy!
  458.             {
  459.                 x=teams[i].tm_x-ballx;
  460.                 y=teams[i].tm_y-bally;
  461.                 d=calc_dist(x,y);
  462.  
  463.                 dif=((x*xp)+(y*yp))/d;
  464.                 if (dif>FACING_ANGLE)
  465.                 {
  466.                     pass_type=in_kicking_range(&teams[setp_taker-1],x,y);
  467.                     if (pass_type!=5 && pass_type!=-1)
  468.                         pass_type=0;
  469.                     else
  470.                         pass_type=-1;
  471.                 }
  472.  
  473.                 if (pass_type)
  474.                 {
  475.                     make_pass(&teams[setp_taker-1],i+1,FALSE);
  476.                     ready_set_kick();
  477.                     break;
  478.                 }
  479.             }
  480.         }
  481.     }
  482.     if (!pass_type)
  483.     {
  484.         setp_kick_x=teams[setp_taker-1].tm_xdis;
  485.         setp_kick_y=teams[setp_taker-1].tm_ydis;
  486.         must_pass=TRUE;
  487.         pass_type=-1;
  488.         make_pass(&teams[setp_taker-1],0,FALSE);
  489.         ready_set_kick();
  490.     }
  491. }
  492.  
  493. /******************************************************************************
  494. *****************************************************************************/
  495.  
  496. void taker_tee_up(float x,float y)
  497. {
  498.     taker_pass_f(x,y);
  499.     must_shoot=TRUE;
  500.     must_punt=TRUE;
  501. }
  502.  
  503. /******************************************************************************
  504. *****************************************************************************/
  505.  
  506. void taker_kick(float x,float y)
  507. {
  508.     if (teams[setp_taker-1].tm_srng)
  509.     {
  510. // In shooting range...
  511.         if (spec_kick_type==SPACT_DRIVE)
  512.             drive_shot=TRUE;
  513.  
  514.         pass_type=-1;
  515.         make_shoot(&teams[setp_taker-1]);
  516.         ready_set_kick();
  517.     }
  518.     else
  519.     {
  520.         make_punt(&teams[setp_taker-1]);
  521.         ready_set_kick();
  522.     }
  523. }
  524.  
  525. /******************************************************************************
  526. *****************************************************************************/
  527.  
  528. void taker_chip(float x,float y)
  529. {
  530.     setp_kick_x=teams[setp_taker-1].tm_xdis;
  531.     setp_kick_y=teams[setp_taker-1].tm_ydis;
  532.     chip_pass=TRUE;
  533.     must_pass=TRUE;
  534.     pass_type=-1;
  535.     make_pass(&teams[setp_taker-1],0,FALSE);
  536.     ready_set_kick();
  537. }
  538.  
  539. /******************************************************************************
  540. *****************************************************************************/
  541.  
  542. void taker_grnd(float x,float y)
  543. {
  544.     setp_kick_x=teams[setp_taker-1].tm_xdis;
  545.     setp_kick_y=teams[setp_taker-1].tm_ydis;
  546.     chip_pass=FALSE;
  547.     must_pass=TRUE;
  548.     pass_type=5;
  549.     make_pass(&teams[setp_taker-1],0,FALSE);
  550.     ready_set_kick();
  551. }
  552.  
  553. /******************************************************************************
  554. *****************************************************************************/
  555.  
  556. #ifdef SUPPORT_LP
  557.  
  558. #define ROTATE_ANG (0.16)
  559.  
  560. void rotate_lp(match_player *player)
  561. {
  562.     float ox=player->tm_xdis;
  563.     float oy=player->tm_ydis;
  564.  
  565.     float rot=0;
  566.  
  567.     short fire=users_dir[user_controlled-1].f;
  568.  
  569.     if (!(fire&LP_L && fire&LP_R))
  570.     {
  571. // Not both shoulder buttons...
  572.         if (fire&LP_L)
  573.             rot=-ROTATE_ANG;
  574.  
  575.         if (fire&LP_R)
  576.             rot=ROTATE_ANG;
  577.  
  578.         player->tm_xdis=(ox*cos(rot))-(oy*sin(rot));
  579.         player->tm_ydis=(oy*cos(rot))+(ox*sin(rot));
  580.         player->tm_x=ballx-(player->tm_xdis*8);
  581.         player->tm_y=bally-(player->tm_ydis*8);
  582.     }
  583. }
  584. #endif
  585.  
  586. /******************************************************************************
  587. *****************************************************************************/
  588.  
  589. void rotate_around_ball(match_player *player)
  590. {
  591.     if (um)
  592.     {
  593.         float x=ballx-(ux*8);
  594.         float y=bally-(uy*8);
  595.         player->tm_x=x;
  596.         player->tm_y=y;
  597.         player->tm_xdis=ux;
  598.         player->tm_ydis=uy;
  599.     }
  600. }
  601.  
  602. /******************************************************************************
  603. *****************************************************************************/
  604.  
  605. void taker_nkick()
  606. {
  607.     newk_shot=TRUE;
  608.     teams[setp_taker-1].tm_xdis=setp_kick_x;
  609.     teams[setp_taker-1].tm_ydis=setp_kick_y;
  610.     pass_type=-1;
  611.     make_shoot(&teams[setp_taker-1]);
  612.     ready_set_kick();
  613. }
  614.  
  615. /******************************************************************************
  616. *****************************************************************************/
  617.  
  618. void draw_tracker(short mp,float x,float y)
  619. {
  620.     static float fract=0;
  621.     float bspeed=get_power();
  622.     ballxdis=x*bspeed;
  623.     ballydis=y*bspeed;
  624.     ballzdis=get_traj();
  625.     ball_inair=TRUE;
  626.     ball_poss=FALSE;
  627.  
  628.     predict_ball();
  629.     ballxdis=0;
  630.     ballydis=0;
  631.     ballzdis=0;
  632.     ball_inair=FALSE;
  633.     ball_poss=setp_taker;
  634.  
  635.     float xp,yp,zp;
  636.  
  637. // Draw tracker...
  638.     for (short i=0; (i<first_bounce || i<mp); i++)
  639.     {
  640. // Marker...
  641.         xp=ball_pred_tab[i][0];
  642.         yp=ball_pred_tab[i][1];
  643.         zp=ball_pred_tab[i][2];
  644.         xp=xp+(fract*(ball_pred_tab[i+1][0]-xp));
  645.         yp=yp+(fract*(ball_pred_tab[i+1][1]-yp));
  646.         zp=zp+(fract*(ball_pred_tab[i+1][2]-zp));
  647.  
  648. // Dot...
  649.         add_pitch_sprite(xp,yp,zp,0);
  650.  
  651. // Shadow...
  652.         add_pitch_sprite(xp,yp,0,1);
  653.     }
  654.  
  655.     fract+=0.2;
  656.     if (fract>=1)
  657.         fract=0;
  658. }
  659.  
  660. /******************************************************************************
  661. *****************************************************************************/
  662.  
  663. void init_runup_act(match_player *player)
  664. {
  665.     init_run_act(player,ballx,bally,TRUE);
  666.     player->int_move=I_RUNUP;
  667.     player->int_cnt=player->go_cnt;
  668.     if (player->int_cnt>0)
  669.         player->int_cnt--;
  670.  
  671. }
  672.  
  673. /******************************************************************************
  674. *****************************************************************************/
  675.  
  676. void user_runup(match_player *player)
  677. {
  678.     if (!player->int_cnt--)
  679.     {
  680. // End of runup...
  681.         spec_kick_type=SPACT_NEWK;
  682.         taker_nkick();
  683.     }
  684.     else
  685.     {
  686.         go_forward(player);
  687.     }
  688. }
  689.  
  690. /******************************************************************************
  691. *****************************************************************************/
  692.  
  693. #define ROT_SPEED (0.05)
  694.  
  695. void new_user_spec_kick(match_player *player)
  696. {
  697.     if (player->int_move==I_RUNUP)
  698.     {
  699.         user_runup(player);
  700.     }
  701.     else
  702.     {
  703.         float x=setp_kick_x;
  704.         float y=setp_kick_y;
  705.  
  706. // Player's maximum power of shot...
  707.         short max_pow=(player->tm_pow/6)+8;
  708.  
  709.         float xd;
  710.         short yd;
  711.  
  712. // Read unvectored user controls...
  713.         if (users_dir[user_controlled-1].f&8)
  714.             xd=-ROT_SPEED*((max_pow)/(setp_power+6));
  715.         else
  716.             if (users_dir[user_controlled-1].f&4)
  717.                 xd=ROT_SPEED*((max_pow)/(setp_power+6));
  718.             else
  719.                 xd=0;
  720.  
  721.         if (users_dir[user_controlled-1].f&32)
  722.             yd=1;
  723.         else
  724.             if (users_dir[user_controlled-1].f&16)
  725.                 yd=-1;
  726.             else
  727.                 yd=0;
  728.  
  729.         if (!uf2)
  730.         {
  731. // Not trying pass...
  732.  
  733. // Rotate player based on (left,right action)...
  734.             setp_kick_x=(x*cos(xd))-(y*sin(xd));
  735.             setp_kick_y=(y*cos(xd))+(x*sin(xd));
  736.             float d=calc_dist(setp_kick_x,setp_kick_y);
  737.             setp_kick_x=setp_kick_x/d;
  738.             setp_kick_y=setp_kick_y/d;
  739.  
  740. // Adjust run-up based on (up,down action)...
  741.             setp_power+=yd;
  742.             if (setp_power<0)
  743.                 setp_power=0;
  744.             else
  745.                 if (setp_power>max_pow)
  746.                     setp_power=max_pow;
  747.         }
  748.  
  749. // Where should he be...
  750.         setp_x=ballx-(setp_kick_x*(setp_power+2)*2);
  751.         setp_y=bally-(setp_kick_y*(setp_power+2)*2);
  752.  
  753.         init_run_act(player,setp_x,setp_y,TRUE);
  754.         if (player->tm_act==RUN_ACT)
  755.             go_forward(player);
  756.         else
  757.         {
  758.             player->tm_x=setp_x;
  759.             player->tm_y=setp_y;
  760.             player->tm_xdis=setp_kick_x;
  761.             player->tm_ydis=setp_kick_y;
  762.         }
  763.  
  764.         if (uf1)
  765.         {
  766. // Shoot button held...
  767.             if (++setp_hgt>30)
  768.                 setp_hgt--;
  769.         }
  770.         else
  771.         {
  772.             if (setp_hgt)
  773. // Shoot button has been released...
  774.                 init_runup_act(player);
  775.  
  776.             if (uf2)
  777.             {
  778.                 if (setp_power || calc_dist(player->tm_x-setp_x,player->tm_y-setp_y)>1)
  779.                     setp_power=0;
  780.                 else
  781.                 {
  782. // At ball... Ready to pass...
  783.                     if (!f2_down)
  784.                     {
  785.                         f2_down=1;
  786.                     }
  787.                 }
  788.             }
  789.             else
  790.             {
  791.                 if (f2_down)
  792.                 {
  793. // uf2 released...
  794.                     if (um)
  795.                     {
  796. // (uf2 + d)...
  797.                         if (uf1)
  798.                             spec_kick_type=SPACT_TEE_UP;    // Tee up for shot or punt!
  799.                         else
  800.                             spec_kick_type=SPACT_DPASS;    // Disguised Pass!
  801.                     }
  802.                     else
  803.                         spec_kick_type=SPACT_FPASS;    // Pass to feet!
  804.                 }
  805.             }
  806.         }
  807.     
  808.         if (!f2_down && setp_power)
  809.             draw_tracker(max_pow/2,setp_kick_x,setp_kick_y);
  810.  
  811.         switch(spec_kick_type)
  812.         {
  813.             case(SPACT_FPASS):
  814.                 taker_pass_f(player->tm_xdis,player->tm_ydis);
  815.                 break;
  816.  
  817.             case(SPACT_HPASS):
  818.                 taker_pass_h(player->tm_xdis,player->tm_ydis);
  819.                 break;
  820.  
  821.             case(SPACT_TEE_UP):
  822.                 taker_tee_up(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  823.                 break;
  824.  
  825.             case(SPACT_DPASS):
  826.                 taker_pass_f(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  827.                 break;
  828.  
  829.             case(SPACT_GRND):
  830.                 taker_grnd(player->tm_xdis,player->tm_ydis);
  831.                 break;
  832.  
  833.             case(SPACT_CHIP):
  834.                 taker_chip(player->tm_xdis,player->tm_ydis);
  835.                 break;
  836.  
  837.             case(SPACT_DRIVE):
  838.                 taker_kick(player->tm_xdis,player->tm_ydis);
  839.                 break;
  840.  
  841.             case(SPACT_KICK):
  842.                 taker_kick(player->tm_xdis,player->tm_ydis);
  843.                 break;
  844.  
  845.             case(SPACT_NEWK):
  846.                 taker_nkick();
  847.                 break;
  848.         }
  849.     }
  850. }
  851.  
  852. /******************************************************************************
  853. *****************************************************************************/
  854.  
  855. void user_pen_kick(match_player *player,char user_guy)
  856. {
  857.     float ydif,racc;
  858.  
  859.     if (player->int_move==I_RUNUP)
  860.     {
  861.         user_runup(player);
  862.     }
  863.     else
  864.     {
  865.         if (player->tm_player<12)
  866.             setp_bxd=pitch_len;
  867.         else
  868.             setp_bxd=0;
  869.  
  870.         float x,y,d;
  871.         float acc=(128.-player->tm_ac)/4;
  872.         float skill=(160.-player->tm_flair)/16;
  873.         setp_power=(player->tm_pow/8)+10;
  874.  
  875.         if (f2_down<0)
  876.         {
  877.             setp_byd-=skill;
  878.             if (setp_byd<(top_post_y-acc))
  879.                 f2_down=1;
  880.         }
  881.         else
  882.         {
  883.             setp_byd+=skill;
  884.             if (setp_byd>(bot_post_y+acc))
  885.                 f2_down=-1;
  886.         }
  887.  
  888. // Derive vector from point on goal-line...
  889.         x=setp_bxd-ballx;
  890.         y=setp_byd-bally;
  891.         d=calc_dist(x,y);
  892.         setp_kick_x=x/d;
  893.         setp_kick_y=y/d;
  894.  
  895.         if (!user_guy)
  896.         {
  897. // Computer intelligence...
  898.             if (!f1_down)
  899.             {
  900. // Not started kick yet...
  901.                 af_randomize();
  902.                 if (seed>(92+((128-player->tm_flair)/8)))
  903.                 {
  904. // Decides to kick...
  905.                     af_randomize();
  906.                     if (seed>(player->tm_flair/2))
  907.                     {
  908. // Aim low... (not very spectacular)
  909.                         setp_bzd=4;
  910.                     }
  911.                     else
  912.                     {
  913. // Aim High... (Spectacular attempt)
  914.                         setp_bzd=16;
  915.                     }
  916.  
  917.                     if (f2_down<0)
  918.                     {
  919. // Targeter moving upward...
  920.                         ydif=setp_byd-(top_post_y+(ball_diam*2)+skill);
  921.                     }
  922.                     else
  923.                     {
  924. // Targeter moving downward...
  925.                         ydif=(bot_post_y-(ball_diam*2)-skill)-setp_byd;
  926.                     }
  927.  
  928.                     if (ABS((ydif/skill)-setp_bzd)<1)
  929.                     {
  930.                         uf1=TRUE;
  931.                         af_randomize();
  932.                         setp_bzd+=((acc-(acc*seed/64)))/2;
  933.                         if (setp_bzd<1)
  934.                             setp_bzd=1;
  935.                     }
  936.                 }
  937.             }
  938.             else
  939.             {
  940.                 if (f1_down>(setp_bzd-1))
  941.                     uf1=FALSE;
  942.                 else
  943.                     uf1=TRUE;
  944.             }
  945.         }
  946.  
  947. // Under user control...
  948.         if (uf1)
  949.         {
  950.             if ((++f1_down)>30)
  951.             {
  952.                 f1_down=30;
  953.             }
  954.             setp_hgt=f1_down;
  955.         }
  956.         else
  957.         {
  958.             if (f1_down)
  959.             {
  960.                 init_runup_act(player);
  961.                 penalty_shot=TRUE;
  962.             }
  963.         }
  964.         draw_tracker(setp_power/2,setp_kick_x,setp_kick_y);
  965.     }
  966. }
  967.  
  968. /******************************************************************************
  969. *****************************************************************************/
  970.  
  971. void user_spec_kick(match_player *player)
  972. {
  973.     setp_taker=player->tm_player;
  974.     if (uf1 && uf2)
  975.     {
  976. // Both buttons held...
  977.         if (um && !f1_down && !f2_down)
  978.         {
  979. // Both pressed together...(take F1!)
  980.             spec_kick_type=SPACT_DRIVE;        // Driving shot or punt!
  981.         }
  982.     }
  983.     else
  984.     {
  985.         if (f2_down && f1_down)
  986.         {
  987. // Both buttons held...
  988.             if (!uf1)
  989.             {
  990. // Both buttons were held but f1 released...
  991.                 if (um)
  992.                 {
  993. // Direction selected...
  994.                     spec_kick_type=SPACT_TEE_UP;    // Tee up for shot or punt!
  995.                 }
  996.                 else
  997.                 {
  998. // No Direction...
  999.                     spec_kick_type=SPACT_CHIP;        // Power Chip into air!
  1000.                 }
  1001.             }
  1002.             else
  1003.             {
  1004.                 if (!uf2)
  1005.                 {
  1006. // Both buttons were held but f2 released...
  1007.                     if (um)
  1008.                     {
  1009. // Direction selected...
  1010.                         spec_kick_type=SPACT_DPASS;    // Disguised pass!
  1011.                     }
  1012.                     else
  1013.                     {
  1014. // No Direction...
  1015.                         spec_kick_type=SPACT_HPASS;    // Pass to head!
  1016.                     }
  1017.                 }
  1018.             }
  1019.         }
  1020.         else
  1021.         {
  1022.             if (f1_down)
  1023.             {
  1024. // F1 held down only...
  1025.                 if (!uf1)
  1026.                 {
  1027. // F1 now released...
  1028.                     if (um)
  1029.                     {
  1030. // Direction selected...
  1031.                         spec_kick_type=SPACT_TEE_UP;    // Tee up for shot or punt!
  1032.                     }
  1033.                     else
  1034.                     {
  1035. // No Direction...
  1036.                           spec_kick_type=SPACT_DRIVE;    // Driving shot or punt(no swerve)!
  1037.                     }
  1038.                 }
  1039.             }
  1040.             else
  1041.             {
  1042.                 if (f2_down)
  1043.                 {
  1044. // F2 held down only...
  1045.                     if (!uf2)
  1046.                     {
  1047. // F2 now released...
  1048.                         if (um)
  1049.                         {
  1050. // Direction selected...
  1051.                             spec_kick_type=SPACT_DPASS;    // Disguised Pass!
  1052.                         }
  1053.                         else
  1054.                         {
  1055. // No Direction...
  1056.                             spec_kick_type=SPACT_GRND;        // Power kick along ground!
  1057.                         }
  1058.                     }
  1059.                 }
  1060.                 else
  1061.                 {
  1062. // No buttons held...
  1063.                     if (uf1 && um)
  1064.                     {
  1065. // F1 pressed initialy with dir...
  1066.                         spec_kick_type=SPACT_KICK;        // Shoot or punt!
  1067.                     }
  1068.                     else
  1069.                     {
  1070.                         if (uf2 && um)
  1071.                         {
  1072. // F2 pressed initialy with dir...
  1073.                             spec_kick_type=SPACT_FPASS;    // Pass to feet!
  1074.                         }
  1075.                     }
  1076.                 }
  1077.             }
  1078.         }
  1079.     }
  1080.  
  1081.     if (!um)
  1082.     {
  1083.         if (uf2)
  1084.         {
  1085.             if (!f2_down && f1_down)
  1086.                 f2_down=1;
  1087.  
  1088.             if (++f2_down>30)
  1089.                 f2_down=30;
  1090.         }
  1091.  
  1092.         if (uf1)
  1093.         {
  1094.             if (!f1_down && f2_down)
  1095.                 f2_down=1;
  1096.  
  1097.             if (++f1_down>30)
  1098.                 f1_down=30;
  1099.         }
  1100.  
  1101.         if (f1_down)
  1102.             setp_power=f1_down;
  1103.         else
  1104.             setp_power=f2_down;
  1105.  
  1106.         setp_bxd=(player->tm_xdis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  1107.         setp_byd=(player->tm_ydis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  1108.         setp_bzd=(setp_power/4)+4;
  1109.  
  1110. #ifdef SUPPORT_LP
  1111.         if (!uf1 && !uf2 && !f1_down && !f2_down && set_piece_on)
  1112.             rotate_lp(player);
  1113. #endif
  1114.  
  1115.     }
  1116.     else
  1117.     {
  1118.         if (!uf1 && !uf2 && !f1_down && !f2_down && set_piece_on)
  1119.             rotate_around_ball(player);
  1120.     }
  1121.  
  1122.     switch(spec_kick_type)
  1123.     {
  1124.         case(SPACT_FPASS):
  1125.             taker_pass_f(player->tm_xdis,player->tm_ydis);
  1126.             break;
  1127.  
  1128.         case(SPACT_HPASS):
  1129.             taker_pass_h(player->tm_xdis,player->tm_ydis);
  1130.             break;
  1131.  
  1132.         case(SPACT_TEE_UP):
  1133.             taker_tee_up(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  1134.             break;
  1135.  
  1136.         case(SPACT_DPASS):
  1137.             taker_pass_f(users_dir[user_controlled-1].x,users_dir[user_controlled-1].y);
  1138.             break;
  1139.  
  1140.         case(SPACT_GRND):
  1141.             taker_grnd(player->tm_xdis,player->tm_ydis);
  1142.             break;
  1143.  
  1144.         case(SPACT_CHIP):
  1145.             taker_chip(player->tm_xdis,player->tm_ydis);
  1146.             break;
  1147.  
  1148.         case(SPACT_DRIVE):
  1149.             taker_kick(player->tm_xdis,player->tm_ydis);
  1150.             break;
  1151.  
  1152.         case(SPACT_KICK):
  1153.             taker_kick(player->tm_xdis,player->tm_ydis);
  1154.             break;
  1155.     }
  1156. }
  1157.  
  1158. /******************************************************************************
  1159. *****************************************************************************/
  1160.  
  1161. void user_limited_kick(match_player *player)
  1162. {
  1163. // Limited for penalty...
  1164.  
  1165.     setp_taker=player->tm_player;
  1166.  
  1167.     if (um)
  1168.     {
  1169. // Directional...
  1170.         if (uf1)
  1171.         {
  1172.             spec_kick_type=SPACT_KICK;            // Shoot!
  1173.         }
  1174.     }
  1175.     else
  1176.     {
  1177.         if (uf1)
  1178.         {
  1179.             spec_kick_type=SPACT_DRIVE;        // Driving shot!
  1180.         }
  1181.     }
  1182.  
  1183.     setp_power=(player->tm_pow/6)+8;
  1184.     setp_bxd=(player->tm_xdis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  1185.     setp_byd=(player->tm_ydis*(setp_power+4)*(128+teams[ball_poss-1].tm_pow))*.5/256;
  1186.     setp_bzd=(setp_power/4)+4;
  1187.  
  1188.     if (!uf1 && !f1_down && set_piece_on)
  1189.         rotate_around_ball(player);
  1190.  
  1191.     switch(spec_kick_type)
  1192.     {
  1193.         case(SPACT_DRIVE):
  1194.             penalty_shot=TRUE;
  1195.             taker_kick(player->tm_xdis,player->tm_ydis);
  1196.             break;
  1197.  
  1198.         case(SPACT_KICK):
  1199.             penalty_shot=TRUE;
  1200.             taker_kick(player->tm_xdis,player->tm_ydis);
  1201.             break;
  1202.     }
  1203. }
  1204.  
  1205. /******************************************************************************
  1206. *****************************************************************************/
  1207.  
  1208. void comp_set_piece(match_player *player)
  1209. {
  1210.     if (refs[0].act==2)
  1211.         user_pen_kick(player,FALSE);
  1212. }
  1213.  
  1214. /******************************************************************************
  1215. *****************************************************************************/
  1216.  
  1217. void user_set_piece(match_player *player)
  1218. {
  1219.     user_conts(&teams[player_num-1]);
  1220.  
  1221. #ifdef STOP_TIME_WASTING
  1222.     if (ref_wait<0)
  1223.     {
  1224. // Force strike on ball (Time-up)...
  1225.         uf1=TRUE;
  1226.         uf2=TRUE;
  1227.         um=TRUE;
  1228.         ux=player->tm_xdis;
  1229.         uy=player->tm_ydis;
  1230.     }
  1231. #endif
  1232.  
  1233.     if (ref_wait)
  1234.     {
  1235.  
  1236.         switch(match_mode)
  1237.         {
  1238.             case(IF_KICK_A):
  1239.             case(IF_KICK_B):
  1240.             case(DF_KICK_A):
  1241.             case(DF_KICK_B):
  1242.             case(CORNER_TL):
  1243.             case(CORNER_BL):
  1244.             case(CORNER_TR):
  1245.             case(CORNER_BR):
  1246.             case(GOAL_KICK_TL):
  1247.             case(GOAL_KICK_BL):
  1248.             case(GOAL_KICK_TR):
  1249.             case(GOAL_KICK_BR):
  1250.             case(CENTRE_A):
  1251.             case(CENTRE_B):
  1252.  
  1253. #ifndef EURO96
  1254.                 user_spec_kick(player);
  1255. #else
  1256.                 new_user_spec_kick(player);
  1257. #endif
  1258.                 break;
  1259.  
  1260.             case(PEN_KICK_A):
  1261.             case(PEN_KICK_B):
  1262. #ifdef EURO96
  1263.                 user_pen_kick(player,TRUE);
  1264. #else
  1265.                 user_limited_kick(player);
  1266. #endif
  1267.                 break;    }
  1268.     }
  1269. }
  1270.  
  1271. /******************************************************************************
  1272. *****************************************************************************/
  1273.  
  1274. void init_throw_act(match_player *player)
  1275. {
  1276.     last_touch=player->tm_player;
  1277.     player->tm_anim=MC_THROWL;
  1278.     player->tm_newanim=TRUE;
  1279.     player->tm_frm=0;
  1280.     player->tm_fstep=MC_THROWL_FS;
  1281.  
  1282.     player->dir_mode=2;
  1283.     player->go_txdis=0;
  1284.     player->go_tydis=0;
  1285.     player->tm_act=THROW_ACT;
  1286.     player->tm_xdis=0;
  1287.     if (player->tm_player<12)
  1288.         player->turn_dir=1;
  1289.     else
  1290.         player->turn_dir=-1;
  1291.  
  1292.     if (bally<cntspot_y)
  1293.         player->tm_ydis=1;
  1294.     else
  1295.         player->tm_ydis=-1;
  1296.     throw_cnt=90;
  1297.  
  1298.     support_me=TRUE;
  1299. }
  1300.  
  1301. /******************************************************************************
  1302. *****************************************************************************/
  1303.  
  1304. void init_get_up(match_player *player,float fs)
  1305. {
  1306.     player->int_cnt=1+(1.0/fs);
  1307.     player->int_move=I_GET_UP;
  1308.     player->dir_mode=2;            // Don't turn!
  1309. }
  1310.  
  1311. /******************************************************************************
  1312. *****************************************************************************/
  1313.  
  1314. void init_pickup_act(match_player *player)
  1315. {
  1316.     reset_ideas(player);
  1317.     player->tm_act=PICKUP_ACT;
  1318.     init_anim(player,MC_PICKBALL);
  1319.     player->int_move=I_GET_UP;            // Look like he is busy!
  1320.     player->int_cnt=1/MC_PICKBALL_FS;
  1321. }
  1322.  
  1323. /******************************************************************************
  1324. *****************************************************************************/
  1325.  
  1326. void pickup_action(match_player *player)
  1327. {    
  1328.     if (!player->int_cnt)
  1329.     {
  1330. // end of animation...
  1331.         if (player->tm_anim==MC_PICKBALL)
  1332.         {
  1333.             init_anim(player,MC_STANDB);
  1334.             ball_in_hands=TRUE;
  1335.             if (player->tm_player==KP_A || player->tm_player==KP_B)
  1336.             {
  1337.                 player->dir_mode=2;
  1338.                 init_kphold_act(player);
  1339.             }
  1340.         }
  1341.     }
  1342. }
  1343.  
  1344. /******************************************************************************
  1345. *****************************************************************************/
  1346.  
  1347. void init_taunt_act(match_player *player)
  1348. {
  1349. // Stationary taunt...
  1350.  
  1351.     player->tm_act=CELEB_ACT;
  1352.     player->go_txdis=0;
  1353.     player->go_tydis=0;
  1354.     player->dir_mode=2;
  1355.  
  1356.     if (player->tm_player==goal_scorer)
  1357.     {
  1358.         scorer_running=FALSE;
  1359. // Choose Taunt...
  1360.         af_randomize();
  1361.         if (seed&2)
  1362.         {
  1363. // Knee slide...
  1364.             init_anim(player,MC_KNEE);
  1365.             player->go_txdis=player->tm_xdis*3;
  1366.             player->go_tydis=player->tm_ydis*3;
  1367.             player->go_cnt=1/MC_KNEE_FS;
  1368.         }
  1369.         else
  1370.         {
  1371. // Taunt...
  1372.             af_randomize();
  1373.             short r=0;
  1374.             if (user_scorer)
  1375.             {
  1376. // User selects celebration...
  1377.                 while(((users_dir[user_scorer-1].f)>>2)&(1<<r));
  1378.                 r--;
  1379.             }
  1380.             else
  1381. // Computer is random...
  1382.                 r=rand_range(4);
  1383.  
  1384.             switch(rand_range(4))
  1385.             {
  1386.                 case(0):
  1387.                     init_anim(player,MC_REEVES);
  1388.                     break;
  1389.  
  1390.                 case(1):
  1391.                     init_anim(player,MC_BABY);
  1392.                     break;
  1393.  
  1394.                 case(2):
  1395.                     init_anim(player,MC_PUMP);
  1396.                     break;
  1397.  
  1398.                 case(3):
  1399.                     init_anim(player,MC_MILLER);
  1400.                     break;
  1401.             }
  1402.         }
  1403.     }
  1404.     else
  1405.     {
  1406. // Do whatever goal scorer is doing...
  1407.         if (teams[goal_scorer-1].tm_anim==MC_KNEE || teams[goal_scorer-1].tm_anim==MC_DUCK)
  1408.         {
  1409.             init_anim(player,MC_KNEE);
  1410.             player->go_txdis=player->tm_xdis*3;
  1411.             player->go_tydis=player->tm_ydis*3;
  1412.             player->go_cnt=1/MC_KNEE_FS;
  1413.         }
  1414.         else
  1415.             if (teams[goal_scorer-1].tm_anim>=MC_KNEE && teams[goal_scorer-1].tm_anim<=MC_REEVES)
  1416.             {
  1417.                 init_anim(player,teams[goal_scorer-1].tm_anim);
  1418.                 if (player->tm_anim==MC_MOON)
  1419.                 {
  1420.                     player->go_txdis=-player->tm_xdis;
  1421.                     player->go_tydis=-player->tm_ydis;
  1422.                 }
  1423.             }
  1424.             else
  1425.                 init_anim(player,MC_CELEB);
  1426.     }
  1427. }
  1428.  
  1429. /******************************************************************************
  1430. *****************************************************************************/
  1431.  
  1432. void init_run_celeb(match_player *player,float tx,float ty)
  1433. {
  1434. // Moving celebration...
  1435.     player->int_move=I_CELEB;
  1436.     init_run_act(player,tx,ty,TRUE);
  1437.     if (player->tm_act!=RUN_ACT)
  1438.         init_taunt_act(player);
  1439.     else
  1440.     {
  1441.         af_randomize();
  1442.         if (player->tm_player==goal_scorer)
  1443.         {
  1444.             scorer_running=TRUE;
  1445.             switch(seed&1)
  1446.             {
  1447.                 case(0):
  1448.                     init_anim(player,MC_FINGER);
  1449.                     break;
  1450.  
  1451.                 case(1):
  1452.                     init_anim(player,MC_PLANE);
  1453.                     break;
  1454.             }
  1455.         }
  1456.         else
  1457.             init_anim(player,MC_FINGER);
  1458.  
  1459.         player->int_cnt=player->go_cnt+1;
  1460.     }
  1461. }        
  1462.  
  1463. /******************************************************************************
  1464. *****************************************************************************/
  1465.  
  1466. void init_stationary_celeb(match_player *player)
  1467. {
  1468. // Stationary celebration...
  1469.     player->tm_act=CELEB_ACT;
  1470.     player->go_txdis=player->tm_xdis;
  1471.     player->go_tydis=player->tm_ydis;
  1472.     player->go_txdis=0;
  1473.     player->go_tydis=0;
  1474.     player->dir_mode=2;
  1475. }
  1476.  
  1477. /******************************************************************************
  1478. *****************************************************************************/
  1479.  
  1480. #define CELEB_RUN_DIST (13*prat)
  1481.  
  1482. void init_celeb_act(match_player *player)
  1483. {
  1484.     reset_ideas(player);            // Stop interception etc.
  1485.  
  1486.     short celeb=seed&1;
  1487.  
  1488. #ifndef EURO96
  1489.     init_anim(player,MC_CELEB);
  1490. #endif
  1491.  
  1492.     if (player->tm_anim==MC_CELEB)
  1493.     {
  1494.         init_stationary_celeb(player);
  1495.     }
  1496.     else
  1497.     {
  1498.         if (player->tm_player==goal_scorer ||
  1499.              (player->tm_player!=goal_scorer && teams[goal_scorer-1].tm_act==RUN_ACT))
  1500.         {
  1501.             if (player->tm_player!=goal_scorer)
  1502.             {
  1503. // Run towards goal scorer...
  1504.                 float x=teams[goal_scorer-1].tm_x;
  1505.                 float y=teams[goal_scorer-1].tm_y;
  1506.                 af_randomize();
  1507.                 x+=(seed-64)/2;
  1508.                 af_randomize();
  1509.                 y+=(seed-64)/2;
  1510.                 init_run_celeb(player,x,y);
  1511.             }
  1512.             else
  1513.             {
  1514.                 float a,b;
  1515.                 float x=player->tm_x;
  1516.                 float y=player->tm_y;
  1517.                 af_randomize();
  1518.                 random_vector(a,b);
  1519.                 x+=(a*CELEB_RUN_DIST);
  1520.                 y+=(b*CELEB_RUN_DIST);
  1521.  
  1522.                 if (x<0)
  1523.                     if (x<-CELEB_RUN_DIST)
  1524.                         init_anim(player,MC_CELEB);
  1525.                     else
  1526.                         x=player->tm_x+(player->tm_x-x);
  1527.  
  1528.                 if (x>pitch_len)
  1529.                     if (x>(CELEB_RUN_DIST+pitch_len))
  1530.                         init_anim(player,MC_CELEB);
  1531.                     else
  1532.                         x=player->tm_x+(player->tm_x-x);
  1533.  
  1534.                 if (y<0)
  1535.                     if (y<-CELEB_RUN_DIST)
  1536.                         init_anim(player,MC_CELEB);
  1537.                     else
  1538.                         y=player->tm_y+(player->tm_y-y);
  1539.  
  1540.                 if (y>pitch_wid)
  1541.                     if (y>(CELEB_RUN_DIST+pitch_wid))
  1542.                         init_anim(player,MC_CELEB);
  1543.                     else
  1544.                         y=player->tm_y+(player->tm_y-y);
  1545.  
  1546.                 if (player->tm_anim==MC_CELEB)
  1547.                     init_taunt_act(player);
  1548.                 else
  1549.                     init_run_celeb(player,x,y);
  1550.             }
  1551.         }
  1552.         else
  1553.         {
  1554. // Goal scorer will be doing his party piece! (follow suit)...
  1555.             init_taunt_act(player);
  1556.         }
  1557.     }
  1558. }
  1559.  
  1560. /******************************************************************************
  1561. *****************************************************************************/
  1562.  
  1563. void celeb_action(match_player *player)
  1564. {
  1565.     player->tm_x+=player->go_txdis;
  1566.     player->tm_y+=player->go_tydis;
  1567.  
  1568.     if (player->tm_anim==MC_KNEE)
  1569.     {
  1570.         player->go_txdis*=0.94;
  1571.         player->go_tydis*=0.94;
  1572.  
  1573.         if ((--player->go_cnt)<1)
  1574.         {
  1575. // Do the Duck!!!
  1576.             init_anim(player,MC_DUCK);
  1577.             player->go_txdis=player->tm_xdis*MC_DUCK_SPD;
  1578.             player->go_tydis=player->tm_ydis*MC_DUCK_SPD;
  1579.         }
  1580.     }
  1581.  
  1582.     if (!just_scored)
  1583.         init_stand_act(player);
  1584. }
  1585.  
  1586. /******************************************************************************
  1587. *****************************************************************************/
  1588.  
  1589. void init_stand_act(match_player *player)
  1590. {
  1591.     player->contact=-1;
  1592.     int ac=player->tm_act;
  1593.     if (ac==SAVE_ACT)
  1594.         keep_dive=FALSE;
  1595.     reset_ideas(player);            // Stop interception etc.
  1596.     player->ls_anim=ABS(player->tm_anim);    // last anim stored!
  1597.     player->ls_frm=player->tm_frm-player->tm_fstep;
  1598.  
  1599.     player->tm_act=STAND_ACT;
  1600.     player->go_txdis=player->tm_xdis;
  1601.     player->go_tydis=player->tm_ydis;
  1602.     player->go_txdis=0;
  1603.     player->go_tydis=0;
  1604.     player->dir_mode=1;
  1605.  
  1606.     if (player->tm_player==KP_A || player->tm_player==KP_B)
  1607.     {
  1608.         if (keeper_down && ac==SAVE_ACT)
  1609.         {
  1610. // This keeper is on ground...
  1611.             if (ball_in_hands && ball_poss==player->tm_player)
  1612.             {
  1613. // Guy has ball in hands...
  1614.                 if (keeper_down<0)
  1615. // Keeper lying left...
  1616.                 {
  1617.                     init_anim(player,MC_STOSBL);
  1618.                     player->tm_fstep*=(keeper_spd*2);
  1619.                     init_kphold_act(player);
  1620.                     init_get_up(player,player->tm_fstep);
  1621.                 }
  1622.                 else
  1623.                 {
  1624.                     if (keeper_down==1)
  1625.                     {
  1626. // Keeper lying right...
  1627.                         init_anim(player,MC_STOSBR);
  1628.                         player->tm_fstep*=(keeper_spd*2);
  1629.                         init_kphold_act(player);
  1630.                         init_get_up(player,player->tm_fstep);
  1631.                     }
  1632.                     else
  1633.                     {
  1634. // Keeper forward crouched...
  1635.                         init_anim(player,MC_CRTOSTB);
  1636.                         player->tm_fstep*=(keeper_spd*2);
  1637.                         init_kphold_act(player);
  1638.                         init_get_up(player,player->tm_fstep);
  1639.                     }
  1640.                 }
  1641.             }
  1642.             else
  1643.             {
  1644. // Doesn't have ball...
  1645.                 if (keeper_down<0)
  1646. // Keeper lying left...
  1647.                 {
  1648.                     init_anim(player,MC_STOSL);
  1649.                     player->tm_fstep*=(keeper_spd*2);
  1650.                     init_get_up(player,player->tm_fstep);
  1651.                 }
  1652.                 else
  1653.                 {
  1654. // Keeper lying right...
  1655.                     init_anim(player,MC_STOSR);
  1656.                     player->tm_fstep*=(keeper_spd*2);
  1657.                     init_get_up(player,player->tm_fstep);
  1658.                 }
  1659.             }
  1660.  
  1661.             keeper_down=0;
  1662.         }
  1663.         else
  1664.         {
  1665. // Keeper standing up...
  1666.             if (ball_in_hands && ball_poss==player->tm_player)
  1667.             {
  1668. // Has ball...
  1669.                 init_anim(player,MC_STANDB);
  1670.                 init_kphold_act(player);
  1671.             }
  1672.             else
  1673.             {
  1674. // Doesn't have ball...
  1675.                 if (match_mode==PEN_KICK_A || match_mode==PEN_KICK_B)
  1676.                     init_anim(player,MC_PENALTY);
  1677.                 else                        
  1678.                     init_anim(player,MC_STAND);
  1679.             }
  1680.         }
  1681.     }
  1682.     else
  1683.     {
  1684.         init_anim(player,MC_STAND);
  1685.     }
  1686. }
  1687.  
  1688. /******************************************************************************
  1689. *****************************************************************************/
  1690.  
  1691. void init_steal_act(match_player *player)
  1692. {
  1693.     player->tm_act=STEAL_ACT;
  1694.     player->go_txdis=player->tm_xdis;
  1695.     player->go_tydis=player->tm_ydis;
  1696.     player->dir_mode=1;
  1697.     init_anim(player,MC_PASSL);
  1698.     reset_ideas(player);            // Stop interception etc.
  1699. }
  1700.  
  1701. /******************************************************************************
  1702. *****************************************************************************/
  1703.  
  1704. void init_kphold_act(match_player *player)
  1705. {
  1706.     keep_timer=6*REAL_SPEED;
  1707.  
  1708.     player->tm_act=KPHOLD_ACT;
  1709.  
  1710.     player->dir_mode=3;
  1711.  
  1712.     reset_ideas(player);            // Stop interception etc.
  1713.     keeper_steps=(1./MC_RUNWITHB_FS);
  1714. }
  1715.  
  1716. /******************************************************************************
  1717. *****************************************************************************/
  1718.  
  1719. float angle_to_target(match_player *player)
  1720. {
  1721.     float x=player->go_xoff;
  1722.     float y=player->go_yoff;
  1723.  
  1724.     float d=calc_dist(x,y);
  1725.  
  1726. // get new normalised vector.
  1727.     float nx=x/d;
  1728.     float ny=y/d;
  1729.  
  1730.     float ox=player->tm_xdis;
  1731.     float oy=player->tm_ydis;
  1732.  
  1733. // get difference (cos a).
  1734.     float dif=((nx*ox)+(ny*oy));
  1735.  
  1736.     if (dif>1.0)
  1737.         dif=1;
  1738.  
  1739.     if (dif<-1.0)
  1740.         dif=-1;
  1741.  
  1742.     return(dif);
  1743. }
  1744.  
  1745. /******************************************************************************
  1746. *****************************************************************************/
  1747.  
  1748. float angle_to_xy(float a,float b,float x,float y)
  1749. {
  1750.     float d=calc_dist(a,b);
  1751.  
  1752. // get new normalised vector.
  1753.     float nx=a/d;
  1754.     float ny=b/d;
  1755.  
  1756.     d=calc_dist(x,y);
  1757.  
  1758.     float ox=x/d;
  1759.     float oy=y/d;
  1760.  
  1761. // get difference (cos a).
  1762.     float dif=((nx*ox)+(ny*oy));
  1763.  
  1764.     if (dif>1.0)
  1765.         dif=1;
  1766.  
  1767.     if (dif<-1.0)
  1768.         dif=-1;
  1769.  
  1770.     return(dif);
  1771. }
  1772.  
  1773. /******************************************************************************
  1774. *****************************************************************************/
  1775.  
  1776. void init_stand_anims(match_player *player)
  1777. {
  1778.     short p=player->tm_player;
  1779.     if (p==KP_A || p==KP_B)
  1780.     {
  1781. // Goal-keeper...
  1782.         if (ball_in_hands && ball_poss==p)
  1783.         {
  1784. // In keeper's hands...
  1785.             init_anim(player,MC_STANDB);
  1786.         }
  1787.         else
  1788.             init_anim(player,MC_STAND);
  1789.     }
  1790.     else
  1791.         init_anim(player,MC_STAND);
  1792. }
  1793.  
  1794. /******************************************************************************
  1795. *****************************************************************************/
  1796.  
  1797. void init_trot_anims(match_player *player)
  1798. {
  1799.     init_anim(player,MC_TROTA);
  1800. }
  1801.  
  1802. /******************************************************************************
  1803. *****************************************************************************/
  1804.  
  1805. void init_run_anims(match_player *player)
  1806. {
  1807.     short p=player->tm_player;
  1808.  
  1809.     if (p==KP_A || p==KP_B)
  1810.     {
  1811. // Goal-keeper...
  1812.         if (ball_in_hands && ball_poss==p)
  1813.         {
  1814. // In keeper's hands...
  1815.             init_anim(player,MC_RUNWITHB);
  1816.         }
  1817.         else
  1818.             init_anim(player,MC_RUN);
  1819.  
  1820.     }
  1821.     else
  1822.         init_anim(player,MC_RUN);
  1823. }
  1824.     
  1825. /******************************************************************************
  1826. *****************************************************************************/
  1827.  
  1828. void init_run_act(match_player *player,float tx,float ty,char s)
  1829. {
  1830.     player->mface=FALSE;
  1831.  
  1832. // Setup target coords...
  1833.     player->go_tx=tx;
  1834.     player->go_ty=ty;
  1835.  
  1836. // Setup target offset...
  1837.     float x=tx-player->tm_x;
  1838.     float y=ty-player->tm_y;
  1839.     player->go_xoff=x;
  1840.     player->go_yoff=y;
  1841.  
  1842.     float d=calc_dist(x,y);        // How far is target!
  1843.  
  1844.     if (d<IM_THERE_DIST)
  1845.     {
  1846. // He is there already...
  1847.         player->tm_x=tx;
  1848.         player->tm_y=ty;
  1849.         init_stand_act(player);
  1850.     }
  1851.     else
  1852.     {
  1853. // Got to travel...
  1854.  
  1855. // Angle facing towards target...
  1856.         float a=angle_to_xy(x,y,player->tm_xdis,player->tm_ydis);
  1857.     
  1858.         if (a>=cos(MAX_TURN))
  1859.         {
  1860. // He is facing target??? (no need to side step!)
  1861.             player->go_step=FALSE;
  1862.             if (s)
  1863.                 s=2;
  1864.         }
  1865.  
  1866. // Now! Should he be side-stepping???
  1867.         if (s && ((player->go_step && d<STEP_RANGE*2) || (!player->go_step && d<STEP_RANGE)))
  1868.         {
  1869. // Jog now!
  1870.             player->go_stop=FALSE;
  1871.             player->go_step=TRUE;
  1872.             player->go_cnt=d/actual_spd(player)+1;
  1873.             player->go_txdis=x/player->go_cnt;
  1874.             player->go_tydis=y/player->go_cnt;
  1875.             init_trot_anims(player);
  1876.             if (s==TRUE)
  1877.                 player->dir_mode=1;        // Face ball.
  1878.             else
  1879.                 player->dir_mode=0;        // Face target.
  1880.         }
  1881.         else
  1882.         {
  1883. // Run now!
  1884.             player->go_step=FALSE;
  1885.             player->go_cnt=get_there_time(player->tm_player,tx,ty);
  1886.             if (player->go_cnt>=2000)
  1887.                 init_stand_act(player);
  1888.             else
  1889.                 player->go_cnt-=must_face_time;
  1890.  
  1891.             player->mface_x=x_face;
  1892.             player->mface_y=y_face;        // Direction he will be facing at target point!
  1893.  
  1894.             if (must_face)
  1895.             {
  1896. // Must get to a target and then face in a certain dir...
  1897.                 player->mface=TRUE;
  1898.                 player->mface_time=must_face_time;
  1899.             }
  1900.     
  1901.             if (stop_and_face)
  1902.             {
  1903. // Quickest way to get to target is to stop and turn then run straight...
  1904.             
  1905.                 player->go_stop=TRUE;
  1906.             
  1907.                 short tt=ABS(acos(a)/MAX_TURN);        // time to turn!
  1908.  
  1909. // Displacement vectors after turning...
  1910.                 player->go_txdis=x/(player->go_cnt-tt);
  1911.                 player->go_tydis=y/(player->go_cnt-tt);
  1912.                 init_stand_anims(player);
  1913.             }
  1914.             else
  1915.             {
  1916.                 player->go_stop=FALSE;
  1917.  
  1918. // Displacement points to target... (not current though!)
  1919.                 player->go_txdis=x/player->go_cnt;
  1920.                 player->go_tydis=y/player->go_cnt;
  1921.                 init_run_anims(player);
  1922.             }
  1923.     
  1924.             player->dir_mode=0;        // Face target.
  1925.  
  1926.             if (user_controlled && uf2)
  1927.             {
  1928. // Run Fast (user only!)...
  1929.                 player->go_txdis=player->go_txdis*1.2;
  1930.                 player->go_tydis=player->go_tydis*1.2;
  1931.             }
  1932.         }
  1933.         player->tm_act=RUN_ACT;
  1934.     }
  1935. }
  1936.  
  1937.  
  1938.  
  1939.  
  1940. /*
  1941. // How long to get there...
  1942.     player->go_cnt=get_there_time(player->tm_player,tx,ty);
  1943.  
  1944. // Face target coords mode...
  1945.     player->dir_mode=0;
  1946.  
  1947.     if ((ABS(x)<=.1) && (ABS(y)<=.1))
  1948.     {
  1949.         if ((user_controlled) && (ball_poss==player->tm_player))
  1950.             init_stand_act(player);
  1951.         else
  1952.             init_stand_act(player);
  1953.     }
  1954.     else
  1955.     {
  1956.         if (player->tm_player==3)
  1957.             player->tm_player=3;
  1958.  
  1959.         if (!shall_i_turn(player,x,y,s))        // Turn if need be (maybe step)!
  1960.         {
  1961.             float dist=calc_dist(x,y);
  1962.             player->go_dist=(int)dist;
  1963.             if (!player->go_step)
  1964.             {
  1965. // Player not trotting...
  1966.                 if ((!ball_in_hands) && ((player->int_move==I_INTERCEPT) || (user_controlled) ||
  1967.                     ((dist>MUST_RUN_DIST) && (ABS(player->tm_anim)==MC_RUN)) ||
  1968.                     ((dist>(MUST_RUN_DIST*2)) && (ABS(player->tm_anim)!=MC_RUN)) ||
  1969.                     (player->tm_player==ball_poss && !ball_in_hands) ||
  1970.                     (plr_facing(x,y,player))))
  1971.                 {
  1972.                     player->go_cnt=((dist)/actual_spd(player));                //No. of steps till target.
  1973.                     init_anim(player,MC_RUN);
  1974.                 }
  1975.                 else
  1976.                 {
  1977.                     if ((player->tm_player==KP_A) || (player->tm_player==KP_B))
  1978.                     {
  1979.                         if (ball_in_hands && ball_poss==player->tm_player)
  1980.                         {
  1981. // kickout run up...
  1982.                             player->go_cnt=((dist)/(actual_spd(player)/4));                //No. of steps till target.
  1983.                             init_anim(player,MC_RUNWITHB);
  1984.                         }
  1985.                         else
  1986.                         {
  1987.                             player->go_cnt=((dist)/(actual_spd(player)/2));                //No. of steps till target.
  1988.                             init_anim(player,MC_JOG);
  1989.                         }
  1990.                     }
  1991.                     else
  1992.                     {
  1993.                         player->go_cnt=dist/(actual_spd(player)/2);                //half speed.
  1994.                         init_anim(player,MC_JOG);
  1995.                     }
  1996.                 }
  1997.             }
  1998.             else
  1999.             {
  2000. // Trot away...
  2001.                 player->go_cnt=dist/(actual_spd(player));                //half speed.
  2002.                 init_anim(player,MC_TROTA);
  2003.                 player->dir_mode=1;        // Face ball.
  2004.             }
  2005.  
  2006.             player->go_cnt++;
  2007.             player->go_txdis=x/player->go_cnt;
  2008.             player->go_tydis=y/player->go_cnt;
  2009.             player->tm_act=RUN_ACT;
  2010.  
  2011.             if (user_controlled && uf2)
  2012.             {
  2013. // Run Fast (user only!)...
  2014.                 player->go_txdis=player->go_txdis*1.2;
  2015.                 player->go_tydis=player->go_tydis*1.2;
  2016.             }
  2017.         }
  2018.     }
  2019. }
  2020. */
  2021.  
  2022.  
  2023. /******************************************************************************
  2024. *****************************************************************************/
  2025.  
  2026. void init_fall(match_player *player)
  2027. {
  2028.     reset_ideas(player);
  2029.     if (ball_poss==player->tm_player)
  2030.         holder_lose_ball();
  2031.  
  2032. //    get_face_xy(player->face_dir,x,y);
  2033.  
  2034.     player->go_txdis=(player->tm_xdis*FALL_RATE);
  2035.     player->go_tydis=(player->tm_ydis*FALL_RATE);
  2036.     player->go_tx=player->tm_x+(player->go_txdis*100);
  2037.     player->go_ty=player->tm_y+(player->go_tydis*100);
  2038.     player->tm_z=0;
  2039.     player->go_cnt=(1/MC_FALLR_FS)-1;
  2040.     player->tm_act=FALL_ACT;
  2041.     player->dir_mode=0;
  2042.     init_anim(player,MC_FALLR);
  2043.     action="Fall";
  2044. }
  2045.  
  2046. /******************************************************************************
  2047. *****************************************************************************/
  2048.  
  2049. void init_jump_act(match_player *player,char dir,char ride)
  2050. {
  2051.     float t;
  2052.  
  2053.     reset_ideas(player);
  2054.  
  2055.     if (dir)
  2056.     {
  2057.         if (ride)
  2058. // Ride tackle... set zdis to length of animation...
  2059.         {
  2060.             player->dir_mode=0;
  2061.             player->tm_act=JUMP_ACT;
  2062.             action="Jump";
  2063.             init_anim(player,MC_RIDEL);
  2064.             player->tm_zdis=(((1.0-player->tm_frm)/player->tm_fstep)-2)*gravity/2;
  2065.         }
  2066.         else
  2067. // Jump as high as poss...
  2068.         {
  2069.             player->tm_zdis=1.0+(float)(player->tm_pow)/32;
  2070.             player->dir_mode=0;
  2071.             player->tm_act=JUMP_ACT;
  2072.             action="Jump";
  2073.             t=((player->tm_zdis/gravity)*2)+1;
  2074.             init_anim(player,MC_J_HEAD);
  2075.             player->tm_fstep=(float)1/t;
  2076.         }
  2077.     }
  2078.     else
  2079.     {
  2080.         if (player->tm_zdis!=0)
  2081.         {
  2082.             player->dir_mode=1;
  2083.             player->tm_act=JUMP_ACT;
  2084.             action="Header";
  2085.             player->go_txdis=0;
  2086.             player->go_tydis=0;
  2087.             t=((player->tm_zdis/gravity)*2)+1;
  2088.             init_anim(player,MC_J_HEAD);
  2089.             player->tm_fstep=(float)1/t;
  2090.         }
  2091.     }
  2092. }
  2093.  
  2094. /******************************************************************************
  2095. *****************************************************************************/
  2096.  
  2097. void jump_action(match_player *player)
  2098. {
  2099.     player->tm_z+=player->tm_zdis;
  2100.     player->tm_zdis-=gravity;
  2101.     go_toward_target(player);
  2102.     if (player->tm_z<=0)
  2103.     {
  2104.         player->tm_z=0;
  2105.         player->tm_zdis=0;
  2106.  
  2107.         init_stand_act(player);
  2108.     }
  2109. }
  2110.  
  2111. /******************************************************************************
  2112. *****************************************************************************/
  2113.  
  2114. void user_init_tackle(match_player *player)
  2115. {
  2116.     if (um)
  2117.     {
  2118. //        if (camera!=6)
  2119. // Flat mode!
  2120.             init_tackle_act(player,player->tm_x+(ux*256),player->tm_y+(uy*256));
  2121. /*
  2122.         else
  2123.  
  2124. // Follow mode!
  2125.         {
  2126.             if (player->tm_act==RUN_ACT)
  2127.                 init_tackle_act(player,player->tm_x+(player->tm_xdis*256)
  2128.                                              ,player->tm_y+(player->tm_ydis*256));
  2129.             else
  2130.             {
  2131.                 float x,y;
  2132.                 forward_joystick(player,x,y);
  2133.                 init_tackle_act(player,player->tm_x+(x*256),player->tm_y+(y*256));
  2134.             }
  2135.         }
  2136. */
  2137.     }
  2138.     else
  2139.     {
  2140.         float x,y;
  2141. //        get_face_xy(player->face_dir,x,y);
  2142.         x=player->tm_xdis;
  2143.         y=player->tm_ydis;
  2144.         init_tackle_act(player,player->tm_x+(x*256),player->tm_y+(y*256));
  2145.     }
  2146. }        
  2147.  
  2148. /******************************************************************************
  2149. *****************************************************************************/
  2150.  
  2151. void init_tackle_act(match_player *player,float tx,float ty)
  2152. {
  2153.     float x,y,d;
  2154.     x=tx-player->tm_x;
  2155.     y=ty-player->tm_y;
  2156.  
  2157.     d=calc_dist(x,y);
  2158.     player->go_tx=player->tm_x+(x/d*30*prat);
  2159.     player->go_ty=player->tm_y+(y/d*30*prat);
  2160.  
  2161.     x=tx-player->tm_x;
  2162.     y=ty-player->tm_y;
  2163.  
  2164.     player->go_xoff=x;
  2165.     player->go_yoff=y;
  2166.  
  2167.     float a=angle_to_xy(x,y,player->tm_xdis,player->tm_ydis);
  2168.  
  2169.     if (a>=cos(MAX_TURN))
  2170.     {
  2171.         inc_tack(player->tm_player);
  2172.         float d=calc_dist(x,y);
  2173.         player->go_cnt=(TACKLE_TURNS);    //no. of steps till target.
  2174.         player->go_txdis=((x)*((player->tm_rate+player->tm_pow+32)/20)/d);
  2175.         player->go_tydis=((y)*((player->tm_rate+player->tm_pow+32)/20)/d);
  2176.         player->tm_act=TACKLE_ACT;
  2177.         action="Tackle";
  2178.         player->dir_mode=0;
  2179.         init_anim(player,MC_S_TACKLE);
  2180.         player->go_cnt=1/MC_S_TACKLE_FS;    //no. of steps till target.
  2181.         play_fx(PS_SLIDING,player->tm_x,player->tm_y);
  2182.     }
  2183. }
  2184.  
  2185. /******************************************************************************
  2186. *****************************************************************************/
  2187.  
  2188. void rotate_offs(int an,float &x,float &y,float &z,float nx,float ny)
  2189. {
  2190.     float d=calc_dist(nx,ny);
  2191.     nx=nx/d;
  2192.     ny=ny/d;
  2193.  
  2194. // Calculate contact offsets with rotation in direction of facing...
  2195.     x=save_offs[((an-MC_AFOOTB)*3)];         //x
  2196.     y=-save_offs[((an-MC_AFOOTB)*3)+1];    //y
  2197.     z=save_offs[((an-MC_AFOOTB)*3)+2];    //z
  2198.  
  2199. // Normal of offset...
  2200.     float dof=calc_dist(x,y);
  2201.     if (dof>1)
  2202.     {
  2203.  
  2204. // Is there any offset present???
  2205.         x=x/dof;
  2206.         y=y/dof;
  2207.  
  2208. // get angle of rotation.
  2209.         float nsx=(x*nx)-(y*ny);
  2210.         float nsy=(y*nx)+(x*ny);
  2211.         x=nsx*dof;
  2212.         y=nsy*dof;
  2213.     }
  2214.     else
  2215.     {
  2216.         x=0;
  2217.         y=0;
  2218.         z=0;
  2219.     }
  2220. }
  2221.  
  2222. /******************************************************************************
  2223. *****************************************************************************/
  2224.  
  2225. void init_save_act(match_player *player,int tx,int ty,int tz,int an,int zone,int bp,int cont)
  2226. {
  2227.     float nx,ny,acc,cacc,sacc;
  2228.  
  2229.     if (!user_controlled && penalty_shot)
  2230.     {
  2231. // Penalty shot... (computer keeper can sometimes dive in wrong direction!)
  2232.         af_randomize();
  2233.         if (seed>(32+((player->tm_flair+player->tm_vis)/3)))
  2234.             ty=player->tm_y-(ty-player->tm_y);
  2235.     }
  2236.  
  2237.     keeper_down=0;
  2238.  
  2239. // Accuracy of 64 gives range of (20 to -20 degrees)...
  2240.     acc=((float)((rand_range(128-player->tm_ac))*(seed&1 ? 1:-1)))/183;
  2241. //    acc=0;
  2242.     cacc=cos(acc);
  2243.     sacc=sin(acc);
  2244.  
  2245.     af_randomize();
  2246.     
  2247.     float x=tx-player->tm_x;
  2248.     float y=ty-player->tm_y;
  2249.  
  2250. // Horz. vector to target...
  2251.     float d=calc_dist(x,y);
  2252.     x=x/d;
  2253.     y=y/d;
  2254.  
  2255. // Add inaccuracy based on stats...
  2256.     nx=(x*cacc)-(y*sacc);
  2257.     ny=(y*cacc)+(x*sacc);
  2258.  
  2259.     newdx=ny;
  2260.     newdy=nx;
  2261.  
  2262.     if ((an>MC_AJUMPC) && (an<=MC_CJUMPBR))
  2263.     {
  2264. // Is he going left or right???
  2265.         if ((nx*(player->tm_y-bally))>(ny*(player->tm_x-ballx)))
  2266.         {
  2267.             newdy=-newdy;
  2268.             an++;
  2269.         }
  2270.         else
  2271.             newdx=-newdx;
  2272.     }
  2273.  
  2274. // Face Ball...
  2275.     newdx=ballx-player->tm_x;
  2276.     newdy=bally-player->tm_y;
  2277.     float nd=calc_dist(newdx,newdy);
  2278.     newdx=newdx/nd;
  2279.     newdy=newdy/nd;
  2280.  
  2281.     if (an==MC_AFOOTC)
  2282.         keeper_down=2;
  2283.  
  2284.     if ((an>=MC_BFOOTCL && an<=MC_BBODYCR) || (an>=MC_CFOOTBL && an<=MC_CBODYCR))
  2285.     {
  2286. // Keeper will hit ground...
  2287.         if (an&1)
  2288. // Going right...
  2289.             keeper_down=1;
  2290.         else
  2291.             keeper_down=-1;
  2292.     }
  2293.  
  2294. // Calculate current mcap offsets for given direction (newdx,newdy)!
  2295.     float sx,sy,sz;
  2296.     rotate_offs(an,sx,sy,sz,newdx,newdy);
  2297. //    rotate_offs(an,sx,sy,sz,player->tm_xdis,player->tm_ydis);
  2298.     save_xoff=sx;
  2299.     save_yoff=sy;
  2300.     save_zoff=sz;
  2301.  
  2302. // Get horz. distance offset from target point to centre of body,
  2303. // based on motion capture animation...
  2304. /*WAIT for mcap data...*/
  2305.     x=(nx*d)-save_xoff;
  2306.     y=(ny*d)-save_yoff;
  2307.  
  2308.     reset_ideas(player);
  2309.  
  2310.     player->tm_act=SAVE_ACT;
  2311.     player->go_cnt=1/player->tm_fstep;
  2312.     if (keeper_on_grnd)
  2313. // Stay down for a bit after save...
  2314.         if (save_block)
  2315.             player->int_cnt=4+((128-player->tm_rate)/12)+1/player->tm_fstep;        // Time to get up!
  2316.         else
  2317.             player->int_cnt=18+1/player->tm_fstep;        // Time to get up!
  2318.     else
  2319.         player->int_cnt=2+1/player->tm_fstep;
  2320.  
  2321.     player->int_move=I_SAVE_WAIT;
  2322.     action="Save";
  2323.     init_anim(player,an);
  2324.  
  2325.     player->dir_mode=5;
  2326. //    player->dir_mode=2;
  2327.  
  2328.      player->go_tx=player->tm_x+x;
  2329.     player->go_ty=player->tm_y+y;
  2330.     player->go_xoff=x;
  2331.     player->go_yoff=y;
  2332.  
  2333.     if (keeper_will_save)
  2334.     {
  2335.         player->go_txdis=x/bp;
  2336.         player->go_tydis=y/bp;
  2337.     }
  2338.     else
  2339.     {
  2340.         player->go_txdis=x/cont;
  2341.         player->go_tydis=y/cont;
  2342.     }
  2343.  
  2344.     d=calc_dist(player->go_txdis,player->go_tydis);
  2345.     if (d>(actual_spd(player)))
  2346.     {
  2347.         player->go_txdis=player->go_txdis*actual_spd(player)/d;
  2348.         player->go_tydis=player->go_tydis*actual_spd(player)/d;
  2349.     }
  2350.         
  2351.     player->tm_zdis=0;
  2352.  
  2353. }
  2354.  
  2355. /******************************************************************************
  2356. *****************************************************************************/
  2357.  
  2358. void go_toward_target(match_player *player)
  2359. {
  2360.     player->tm_x+=(player->go_txdis);
  2361.     player->tm_y+=(player->go_tydis);
  2362. }
  2363.  
  2364. /******************************************************************************
  2365. *****************************************************************************/
  2366.  
  2367. void go_forward(match_player *player)
  2368. {
  2369.     float rate=actual_spd(player);
  2370.  
  2371.     if (player->go_step)
  2372.     {
  2373. // Player is trotting facing ball...
  2374.         player->tm_x+=(player->go_txdis);
  2375.         player->tm_y+=(player->go_tydis);
  2376.         inc_work(player->tm_player);
  2377.     }
  2378.     else
  2379.     {
  2380. // Player is aiming to run straight at target...
  2381.  
  2382.         if (player->go_stop)
  2383.         {
  2384. // Player must wait until he faces target before moving on...
  2385.  
  2386.             float a=angle_to_xy(player->go_txdis,player->go_tydis,player->tm_xdis,player->tm_ydis);
  2387.                         
  2388.             if (a>=cos(MAX_TURN))
  2389.             {
  2390. // Now facing target... (can move forward!)
  2391.                 player->go_stop=FALSE;
  2392.                 player->tm_x+=(player->go_txdis);
  2393.                 player->tm_y+=(player->go_tydis);
  2394.                 inc_work(player->tm_player);
  2395.                 init_run_anims(player);
  2396.             }
  2397.             else
  2398.             {
  2399. // Stand on the spot...
  2400.             }
  2401.         }
  2402.         else
  2403.         {
  2404. // Run forward in present dir at turn speed...
  2405.  
  2406.             float a=angle_to_xy(player->go_tx-player->tm_x,player->go_ty-player->tm_y,player->tm_xdis,player->tm_ydis);
  2407.             float turn_spd=(1.0+a)/2;
  2408.             player->go_txdis=player->tm_xdis*turn_spd*rate;
  2409.             player->go_tydis=player->tm_ydis*turn_spd*rate;
  2410.  
  2411.             player->tm_x+=(player->go_txdis);
  2412.             player->tm_y+=(player->go_tydis);
  2413.             inc_work(player->tm_player);
  2414.         }
  2415.     }
  2416. }
  2417.  
  2418. /******************************************************************************
  2419. *****************************************************************************/
  2420.  
  2421. void scorer_go(match_player *player)
  2422. {
  2423.     init_celeb_act(player);
  2424. }
  2425.  
  2426. /*
  2427.     float xoff=cntspot_x-player->tm_x;
  2428.     float yoff=cntspot_y-player->tm_y;
  2429.     xoff+=64-seed;
  2430.     af_randomize();
  2431.     yoff+=64-seed;
  2432.     float step=(calc_dist(xoff,yoff)/actual_spd(player));
  2433.     player->go_txdis=xoff/step;
  2434.     player->go_tydis=yoff/step;
  2435.     init_jump_act(player,TRUE);
  2436. }
  2437. */
  2438.  
  2439. /******************************************************************************
  2440. *****************************************************************************/
  2441.  
  2442. void player_shame(match_player *player)
  2443. {
  2444.     init_anim(player,MC_SHAME);
  2445.     init_get_up(player,MC_SHAME_FS);
  2446. }
  2447.  
  2448. /******************************************************************************
  2449. *****************************************************************************/
  2450.  
  2451. void go_to_scorer(match_player *player)
  2452. {
  2453.     int gs=goal_scorer;
  2454.     if (player->tm_act<TURN_ACT)
  2455.     {
  2456.         float x=teams[gs-1].tm_x;
  2457.         float y=teams[gs-1].tm_y;
  2458.         float d=calc_dist(x-player->tm_x,y-player->tm_y);
  2459.         short dp=(player->tm_player>11 ? (player->tm_player-11):(player->tm_player));
  2460.         dp=dp*6;
  2461.         if (d<8+dp)
  2462.             init_celeb_act(player);
  2463.         else
  2464.         {
  2465.             init_run_act(player,x,y,TRUE);
  2466.             {
  2467.                 if (player->tm_act==RUN_ACT)
  2468.                 {
  2469.                     go_forward(player);
  2470.                     player->go_cnt=0;
  2471.                 }
  2472.             }
  2473.         }
  2474.     }
  2475. }
  2476.  
  2477. /******************************************************************************
  2478. *****************************************************************************/
  2479.  
  2480. void someone_has_scored(match_player *player)
  2481. {
  2482.     if (player->int_move!=I_CELEB && (goal_scorer==player->tm_player || (player->tm_player!=KP_A && player->tm_player!=KP_B)))
  2483.     {
  2484.  
  2485.         if (last_goal==1)
  2486.         {
  2487. // Goal for team A...
  2488.             if (goal_scorer<12)
  2489.             {
  2490. // Celebrate...
  2491.                 if (goal_scorer==player->tm_player)
  2492. // He scored!
  2493.                     scorer_go(player);
  2494.                 else
  2495.                     if (player->tm_player<12)
  2496. // His team-mate
  2497.                         go_to_scorer(player);
  2498.                     else
  2499.                         init_stand_act(player);
  2500.             }
  2501.             else
  2502.             {
  2503. // Own goal( Shame!    )
  2504.                 if (goal_scorer==player->tm_player)
  2505. // He scored!
  2506.                     player_shame(player);
  2507.                 else
  2508.                     init_stand_act(player);
  2509.             }
  2510.         }
  2511.         else
  2512.         {
  2513. // Goal for team B...
  2514.             if (goal_scorer>11)
  2515.             {
  2516. // Celebrate...
  2517.                 if (goal_scorer==player->tm_player)
  2518. // He scored!
  2519.                     scorer_go(player);
  2520.                 else
  2521.                     if (player->tm_player>11)
  2522. // His team-mate
  2523.                         go_to_scorer(player);
  2524.                     else
  2525.                         init_stand_act(player);
  2526.             }
  2527.             else
  2528.             {
  2529. // Own goal( Shame!    )
  2530.                 if (goal_scorer==player->tm_player)
  2531. // He scored!
  2532.                     player_shame(player);
  2533.                 else
  2534.                     init_stand_act(player);
  2535.             }
  2536.         }
  2537.     }
  2538.     else
  2539.         if (player->int_move!=I_CELEB)
  2540.             init_stand_act(player);
  2541. }
  2542.  
  2543. /******************************************************************************
  2544. *****************************************************************************/
  2545.  
  2546. void dont_run_off(match_player *player)
  2547. {
  2548.     if ((ballx<16) || (ballx>pitch_len-16) ||
  2549.          (bally<16) || (bally>pitch_wid-16))
  2550.         init_stand_act(player);
  2551. }        
  2552.  
  2553. /******************************************************************************
  2554. *****************************************************************************/
  2555.  
  2556. void user_stand(match_player *player)
  2557. {
  2558.  
  2559. //    if (camera!=6)
  2560. // Flat mode!
  2561.         if (!f1_down && !f2_down)
  2562. // Not doing special...
  2563.             if (game_action==-1)
  2564. // Should take up zonal position...
  2565.                 find_zonal_target(player,player->tm_x,player->tm_y);    //players x,y for comparison.
  2566.             else
  2567.                 init_run_act(player,player->tm_x+ux*256,player->tm_y+uy*256,FALSE);
  2568. /*
  2569.     else
  2570.  
  2571. // Follow mode!
  2572.     {
  2573.         float x,y;
  2574.         forward_joystick(player,x,y);
  2575.         if (uy<0)
  2576.             if (!match_mode && game_action==1)
  2577. // Should take up zonal position...
  2578.                 find_zonal_target(player,player->tm_x,player->tm_y);    //players x,y for comparison.
  2579.             else
  2580.                 init_run_act(player,player->tm_x+x*256,player->tm_y+y*256,FALSE);
  2581.         else
  2582.         {
  2583.             player->go_txdis=x;
  2584.             player->go_tydis=y;
  2585.         }
  2586.     }
  2587. */
  2588.     player->go_cnt=1;
  2589. }        
  2590.  
  2591. /******************************************************************************
  2592. *****************************************************************************/
  2593.  
  2594. /*
  2595. void check_for_header(match_player *player)
  2596. {
  2597.     if ((ball_inair) && (!ball_poss))
  2598. //        && (player->int_move==I_INTERCEPT) && (player->int_cnt))
  2599.     {
  2600.  
  2601.         int meet=200;
  2602.         prev_d=5000;
  2603.         for (int i=0; i<24; i++)
  2604.         {
  2605.             x=ball_pred_tab[i][0];
  2606.             y=ball_pred_tab[i][1];
  2607.             z=ball_pred_tab[i][2];
  2608.  
  2609.             d=calc_dist(x-player->tm_x,y-player->tm_y);
  2610.  
  2611. // Volley???
  2612.             if (ballx>
  2613.  
  2614.             if (ballz>
  2615.             if (d<min_d)
  2616.             {
  2617.                 min_d=d;
  2618.                 meet=i;
  2619.             }
  2620.             else
  2621.                 i=21;            // end loop (not getting closer to ball)
  2622.  
  2623.             prev_d=d;
  2624.         }
  2625.         if (meet!=200)
  2626.         {
  2627. // Ball has a closest point...
  2628.             x=ball_pred_tab[meet][0];
  2629.             y=ball_pred_tab[meet][1];
  2630.             z=ball_pred_tab[meet][2];
  2631.  
  2632.  
  2633.  
  2634.             z=z-PLAYER_HEIGHT+5;
  2635.  
  2636. //            float    zd=sqrt(z)-(gravity*gravity);            // Take-off speed for given max height!
  2637.  
  2638.             float zd=sqrt(2*z*gravity)-(gravity*gravity);                    // Max. Height
  2639.             int jt=gravity+zd/gravity;            // Time to reach max height.
  2640.  
  2641.             jt=meet-jt;
  2642.             
  2643.             if (jt>=0)
  2644.             {
  2645.                 reset_ideas(player);
  2646.                 player->int_cnt=jt;
  2647.                 player->int_move=I_HEADER;    // Wait for header.
  2648.                 player->tm_zdis=zd;
  2649.             }
  2650.         }
  2651.     }
  2652. }
  2653. */
  2654.  
  2655. /******************************************************************************
  2656. *****************************************************************************/
  2657.  
  2658. void kick_strike(match_player *player)
  2659. {
  2660.     if (player->tm_srng)
  2661.     {
  2662. // In Shooting Range!
  2663.         shoot_ball(player);
  2664.     }
  2665.     else
  2666.     {
  2667.         punt_ball(player);
  2668.     }
  2669. }
  2670.  
  2671. /******************************************************************************
  2672. *****************************************************************************/
  2673.  
  2674. void overhead_strike(match_player *player)
  2675. {
  2676.     player->tm_xdis=-player->tm_xdis;
  2677.     player->tm_ydis=-player->tm_ydis;        // Facing backwards...
  2678.  
  2679.     int p=player->tm_pow;
  2680.     player->tm_pow=p*2/3;            // 2 3rds power of kick!
  2681.  
  2682.     if (player->tm_srng)
  2683.     {
  2684. // In Shooting Range!
  2685.         shoot_ball(player);
  2686.     }
  2687.     else
  2688.     {
  2689.         punt_ball(player);
  2690.     }
  2691.  
  2692.     player->tm_xdis=-player->tm_xdis;
  2693.     player->tm_ydis=-player->tm_ydis;
  2694.     player->tm_pow=p;
  2695. }
  2696.  
  2697. /******************************************************************************
  2698. *****************************************************************************/
  2699.  
  2700. void chip_strike(match_player *player)
  2701. {
  2702.     pass_type=player->tm_fpass_type;
  2703.     receiver=player->tm_fpass_to;
  2704.     pass_ball(receiver,FALSE);
  2705. }
  2706.  
  2707. /******************************************************************************
  2708. *****************************************************************************/
  2709.  
  2710. void head_strike(match_player *player)
  2711. {
  2712.     heading_ball=TRUE;
  2713.     if (player->tm_fpass_type)
  2714.     {
  2715.         pass_type=player->tm_fpass_type;
  2716.         receiver=player->tm_fpass_to;
  2717.         pass_ball(receiver,FALSE);
  2718.     }
  2719.     else
  2720.     {
  2721.         int p=player->tm_pow;
  2722.         player->tm_pow=p/2;            // Half power of kick!
  2723.  
  2724.         if (player->tm_srng)
  2725.         {
  2726. // In Shooting Range!
  2727.             if (user_controlled)
  2728.             {
  2729.                 if (uf1)        // Head down!
  2730.                     heading_ball=3;
  2731.             }
  2732.             else
  2733.                 if (seed<player->tm_ac)
  2734.                     heading_ball=3;
  2735.             
  2736.             shoot_ball(player);
  2737.         }
  2738.         else
  2739.         {
  2740.             punt_ball(player);
  2741.         }
  2742.  
  2743.         player->tm_pow=p;
  2744.     }
  2745.     heading_ball=FALSE;
  2746. }
  2747.  
  2748. /******************************************************************************
  2749. *****************************************************************************/
  2750.  
  2751. void dvhead_strike(match_player *player)
  2752. {
  2753.     int p=player->tm_pow;
  2754.     player->tm_pow=p/2;            // Half power of kick!
  2755.     heading_ball=2;
  2756.  
  2757.     short ps=pass_decide(player,FALSE);
  2758.     if (ps && pass_type>=3)
  2759.     {
  2760.         pass_ball(ps,FALSE);
  2761.     }
  2762.     else
  2763.     {
  2764.         if (player->tm_srng)
  2765.         {
  2766. // In Shooting Range!
  2767.             shoot_ball(player);
  2768.         }
  2769.         else
  2770.         {
  2771.             punt_ball(player);
  2772.         }
  2773.     }
  2774.     player->tm_pow=p;
  2775.     heading_ball=FALSE;
  2776. }
  2777.  
  2778. /******************************************************************************
  2779. *****************************************************************************/
  2780.  
  2781. void strike_ball_off(match_player *player)
  2782. {
  2783.     add_comp_pass(player->tm_player);
  2784.     player->tm_ftime=-1;
  2785.     last_touch=player->tm_player;
  2786.     if (last_touch!=KP_A && last_touch!=KP_B)
  2787.         pre_kp_touch=last_touch;
  2788.  
  2789.     ball_poss=player->tm_player;
  2790.     int a=player->tm_anim;
  2791.     switch(a)
  2792.     {
  2793.         case(MC_OVERHEAD):
  2794.             overhead_strike(player);
  2795.             break;
  2796.  
  2797.         case(MC_DV_HEAD):
  2798.             dvhead_strike(player);
  2799.             break;
  2800.  
  2801.         case(MC_J_HEAD):
  2802.         case(MC_S_HEAD):
  2803.             head_strike(player);
  2804.             break;
  2805.  
  2806.         case(MC_CHIPL):
  2807.         case(MC_CHIPR):
  2808.             chip_strike(player);
  2809.             break;
  2810.  
  2811.         case(MC_SHOOTL):
  2812.         case(MC_SHOOTR):
  2813.         case(MC_VOLLEYL):
  2814.         case(MC_VOLLEYR):
  2815.             kick_strike(player);
  2816.             break;
  2817.     }
  2818.  
  2819.     standard_fstep(player);
  2820. }
  2821.  
  2822. /******************************************************************************
  2823. *****************************************************************************/
  2824.  
  2825. void fire_ball_off()
  2826. {
  2827.     reset_shot();
  2828.     if (kick_type==KT_PUNT)
  2829.     {
  2830. // Punt...
  2831.         punt_ball(&teams[ball_poss-1]);
  2832.     }
  2833.     else
  2834.     {
  2835.         if (kick_type==KT_SHOOT)
  2836.         {
  2837. // Shoot...
  2838.             shoot_ball(&teams[ball_poss-1]);
  2839.         }
  2840.         else
  2841.         {
  2842.             pass_ball(receiver,cross_now);
  2843.             cross_now=FALSE;
  2844.             chip_pass=FALSE;
  2845.             action="Pass";
  2846.         }
  2847.     }
  2848.  
  2849.     float sp;
  2850.     int fx;
  2851.  
  2852.     sp=calc_dist(ballxdis,ballydis);
  2853.     sp=calc_dist(sp,ballzdis);
  2854.  
  2855.     if (sp<10)
  2856.         fx=PS_SOFTKICK;
  2857.     else
  2858.         if (sp<14)
  2859.             fx=PS_MEDKICK;
  2860.         else
  2861.             fx=PS_HARDKICK;
  2862.  
  2863.     play_fx(fx,ballx,bally);
  2864.  
  2865. //    process_ball();
  2866. }
  2867.  
  2868. /******************************************************************************
  2869. *****************************************************************************/
  2870.  
  2871. void init_kick_act(match_player *player,int mc,float pc)
  2872. {
  2873.     init_anim(player,mc);
  2874.     player->tm_fstep=player->tm_fstep*player->tm_mcspd;
  2875.     player->contact=pc;
  2876.     if (!set_piece_on)
  2877.         player->dir_mode=0;
  2878.     else
  2879.         player->dir_mode=2;
  2880.  
  2881.     reset_ideas(player);            // Stop interception etc.
  2882.     player->int_move=I_KICKED;
  2883.     player->int_cnt=((1.0-player->tm_frm)/player->tm_fstep)+1;
  2884.     rotate_offs(ABS(player->tm_anim),b_xoff,b_yoff,b_zoff,teams[ball_poss-1].tm_xdis,teams[ball_poss-1].tm_ydis);
  2885.     player->go_txdis=MC_PASS_DIST*player->tm_fstep*player->tm_xdis;
  2886.     player->go_tydis=MC_PASS_DIST*player->tm_fstep*player->tm_ydis;
  2887.     player->go_tx=player->tm_x+player->tm_xdis*100;
  2888.     player->go_ty=player->tm_y+player->tm_ydis*100;
  2889.     player->tm_act=KICK_ACT;
  2890. }    
  2891.  
  2892. /******************************************************************************
  2893. *****************************************************************************/
  2894.  
  2895. void kick_action(match_player *player)
  2896. {
  2897.     if (player->tm_frm+player->tm_fstep>=1)
  2898.     {
  2899. // Finished kick animation...
  2900.         
  2901.         init_stand_act(player);
  2902.         player->contact=-1;
  2903.     }
  2904.  
  2905.     if (player->tm_frm>=player->contact && ball_poss==player->tm_player)
  2906.     {
  2907. // Contacted ball (release it)...
  2908.         fire_ball_off();
  2909.     }
  2910.  
  2911.     if (ball_poss!=player->tm_player && player->tm_frm<player->contact)
  2912.     {
  2913. // Ball stolen before kick!
  2914.         init_stand_act(player);
  2915.         player->contact=-1;
  2916.     }
  2917.     else
  2918.         go_toward_target(player);
  2919. }
  2920.  
  2921. /******************************************************************************
  2922. *****************************************************************************/
  2923.  
  2924. void steal_action(match_player *player)
  2925. {
  2926.     if (player->tm_frm<1.0)
  2927.     {
  2928.         if ((player->tm_frm>0.4) && (player->tm_frm<0.6)
  2929.             && (ballz<1) && (ball_poss!=player->tm_player))
  2930. // Foot out frames...
  2931.         {
  2932. // Get foot coords...
  2933.             float x=player->tm_x+(player->tm_xdis*prat);
  2934.             float y=player->tm_y+(player->tm_ydis*prat);
  2935.             x=ballx-x;
  2936.             y=bally-y;
  2937.             float d=calc_dist(x,y);
  2938.             if (d<=STEAL_FOOT_DIST)
  2939.             {
  2940.                 holder_lose_ball();
  2941.                 collect_ball(player);
  2942.             }
  2943.         }
  2944.     }
  2945.     else
  2946.     {
  2947.         init_stand_act(player);
  2948.     }
  2949. }
  2950.  
  2951. /******************************************************************************
  2952. *****************************************************************************/
  2953.  
  2954. void stand_action(match_player *player)
  2955. {
  2956.     if (player->tm_strike>0 && player->int_move==I_INTERCEPT)
  2957.     {
  2958. // Waiting for first touch...
  2959.         if (--player->go_cnt<=0)
  2960. // Begin first touch animation...
  2961.             init_strike_act(player);
  2962.     }
  2963.     else
  2964.     {
  2965.         if (ABS(player->tm_anim)==MC_SOCKSL || ABS(player->tm_anim)==MC_SOCKSR)
  2966. // Pulling his socks up just now...
  2967.         {
  2968.             if (player->tm_frm>0.99)
  2969.                 init_anim(player,MC_STAND);
  2970.         }
  2971.     
  2972.         player->ls_anim=ABS(player->tm_anim);        // Do not use last anim!
  2973.         player->ls_frm=player->tm_frm;        // Do not use last anim!
  2974.  
  2975.         if ((user_controlled) && (!match_mode)
  2976.              && (!((player->tm_player==KP_A || player->tm_player==KP_B)
  2977.              && ABS(player->tm_anim)>=MC_STOSL && ABS(player->tm_anim)<=MC_STOSBR)))
  2978.             user_stand(player);
  2979.         else
  2980.         {
  2981.             if (ABS(player->tm_anim)>=MC_STOSL && ABS(player->tm_anim)<=MC_STOSBR)
  2982.             {
  2983. // Keeper getting up!
  2984.                 if (!player->int_cnt)
  2985.                 {
  2986.                     if (ball_in_hands)
  2987.                         init_anim(player,MC_STANDB);
  2988.                     else
  2989.                         init_anim(player,MC_STAND);
  2990.                 }
  2991.             }
  2992.             else
  2993.             {
  2994.                 if (just_scored>0)
  2995.                     someone_has_scored(player);
  2996.                 else
  2997.                 {
  2998. //                if (player->int_move!=I_HEADER)
  2999. //                    check_for_header(player);
  3000. //                else
  3001.                     if (player->int_move==I_HEADER)
  3002.                     {
  3003.                         if (player->int_cnt<=1)
  3004.                         {
  3005.                             player->int_cnt=-1;
  3006.                             init_jump_act(player,FALSE);    // Jump straight up!
  3007.                         }
  3008.                     }
  3009.                     else
  3010.                     {
  3011.                         if ((player->tm_player==KP_A && !(ballx<cntspot_x && shot_pending))
  3012.                             || (player->tm_player==KP_B && !(ballx>cntspot_x && shot_pending))
  3013.                             || (player->tm_player!=KP_A && player->tm_player!=KP_B))
  3014.                         {
  3015. // Make sure that keeper isn't waiting to make save!
  3016.                             if ((player->tm_act==STAND_ACT) && (!player->tm_stopped))
  3017.                                 find_zonal_target(player,player->tm_x,player->tm_y);    //players x,y for comparison.
  3018.                         }
  3019.                     }
  3020.                 }
  3021.             }
  3022.         }
  3023.  
  3024.         if (ABS(player->tm_anim)==MC_STAND && player->tm_dist>(prat*50))
  3025.         {
  3026. // Standing far away from ball...
  3027.             if ((ball_poss>11 && player->tm_player>11) || (ball_poss 
  3028.                 && ball_poss<12 && player->tm_player<12))
  3029. // Team-mate has ball (safe!)...
  3030.             {
  3031.                 if (seed<SOCKS_PROB)
  3032.                 {
  3033.                     if (seed&1)
  3034.                         init_anim(player,MC_SOCKSL);
  3035.                     else
  3036.                         init_anim(player,MC_SOCKSR);
  3037. // Busy now...
  3038.                     init_get_up(player,MC_SOCKS_FS);
  3039.                 }
  3040.             }
  3041.         }                
  3042.     }
  3043. }
  3044.  
  3045. /******************************************************************************
  3046. *****************************************************************************/
  3047.  
  3048. void user_throw(match_player *player)
  3049. {
  3050.     char high=FALSE;
  3051.     float x,y;
  3052.  
  3053.     if (um)
  3054. // Joystick_dir...
  3055.     {
  3056.         if (bally>cntspot_y)
  3057. // Bottom line...
  3058.         {
  3059.             x=ux;
  3060.             y=uy;
  3061.  
  3062.             if (uy>0)
  3063.             {
  3064.                 high=TRUE;
  3065.                 y=-uy;
  3066.             }
  3067.             else
  3068.                 high=FALSE;
  3069.         }
  3070.         else
  3071. // Top line...
  3072.         {
  3073.             x=ux;
  3074.             y=uy;
  3075.  
  3076.             if (uy<0)
  3077.             {
  3078.                 high=TRUE;
  3079.                 y=-uy;
  3080.             }
  3081.             else
  3082.                 high=FALSE;
  3083.         }
  3084.             
  3085.         player->tm_xdis=x;
  3086.         player->tm_ydis=y;
  3087.  
  3088.         if (uf2)
  3089. // Pass to nearest team-mate...
  3090.         {
  3091.             must_pass=TRUE;
  3092.             throw_cnt=1;
  3093.             if (high)
  3094.                 chip_pass=TRUE;
  3095.  
  3096.             int p=pass_decide(player,FALSE);
  3097.             make_pass(player,p,FALSE);
  3098.             dead_ball_cnt=0;
  3099.             game_action=0;
  3100.             just_thrown=20;
  3101.             match_mode=0;
  3102.             arrow_on=FALSE;
  3103.             already_there=FALSE;
  3104.             stop_clock=FALSE;
  3105.         }
  3106.  
  3107.         if (uf1)
  3108. // Throw straight...
  3109.         {
  3110.             float sx,sy,sz;
  3111.             float power=5+(player->tm_pow/16);
  3112.             ballxdis=player->tm_xdis*power;
  3113.             ballydis=player->tm_ydis*power;
  3114.             ballzdis=(high ? power:power/2);
  3115.  
  3116.             init_anim(player,MC_THROWL);
  3117. // Point at which ball leaves hand!
  3118. // Calculate current mcap offsets for given direction (newdx,newdy)!
  3119.             rotate_offs(MC_THROWL,sx,sy,sz,player->tm_xdis,player->tm_ydis);
  3120.             ballx=player->tm_x+sx;
  3121.             bally=player->tm_y+sy;
  3122.             ballz=player->tm_z+sz;
  3123.             ball_limbo(player->tm_player,MCC_THROWL);
  3124.             player->tm_limbo=1/MC_THROWL_FS;
  3125.  
  3126.             ball_inair=TRUE;
  3127.             holder_lose_ball();
  3128.             dead_ball_cnt=0;
  3129.             game_action=0;
  3130.             just_thrown=20;
  3131.             match_mode=0;
  3132.             arrow_on=FALSE;
  3133.             already_there=FALSE;
  3134.             stop_clock=FALSE;
  3135.  
  3136.             launch_ball(1);            // Set up spin vector.
  3137.         }
  3138.     }
  3139. }
  3140.  
  3141. /******************************************************************************
  3142. *****************************************************************************/
  3143.  
  3144. void throw_action(match_player *player)
  3145. {
  3146.  
  3147. // Lmen normal...
  3148.     refs[1].act=0;
  3149.     refs[2].act=0;
  3150.  
  3151.     if (refs[0].act!=2)
  3152.     {
  3153. // Referee wait for kick mode...
  3154.         refs[0].act=2;
  3155.         ktaker=player->tm_player;
  3156.         ref_wait=(160-ref_strictness)*REAL_SPEED/8;
  3157.         play_fx(PS_SHORTWHISTLE,refs[0].x,refs[0].y);
  3158.     }
  3159.  
  3160.     if (user_controlled)
  3161.         user_throw(player);
  3162.     else
  3163.     {
  3164.         if (player->dir_mode==2)
  3165.         {
  3166. // Scan in all directions for team-mate...
  3167.             float ang_add,nx,ny;
  3168.             float ox=player->go_txdis;
  3169.             float oy=player->go_tydis;
  3170.  
  3171.             if (player->turn_dir>0)
  3172.                 ang_add=0.1047198;         // 6 degrees (radians)
  3173.             else
  3174.                 ang_add=-0.1047198;
  3175.  
  3176.             nx=(ox*cos(ang_add))-(oy*sin(ang_add));
  3177.             ny=(oy*cos(ang_add))+(ox*sin(ang_add));
  3178.  
  3179.             if (ny>1)
  3180.             {
  3181.                 ny=1;
  3182.                 nx=0;
  3183.             }
  3184.  
  3185.             if (ny<-1)
  3186.             {
  3187.                 ny=-1;
  3188.                 nx=0;
  3189.             }
  3190.  
  3191.             if ((bally<cntspot_y) && (ny<=0))
  3192.             {
  3193.                 player->turn_dir=-player->turn_dir;
  3194.                 ny=0;
  3195.                 if (nx>0)
  3196.                     nx=1;
  3197.                 else
  3198.                     nx=-1;
  3199.             }
  3200.  
  3201.             if ((bally>cntspot_y) && (ny>=0))
  3202.             {
  3203.                 player->turn_dir=-player->turn_dir;
  3204.                 ny=0;
  3205.                 if (nx>0)
  3206.                     nx=1;
  3207.                 else
  3208.                     nx=-1;
  3209.             }
  3210.  
  3211.             player->go_txdis=nx;
  3212.             player->go_tydis=ny;
  3213.     
  3214.             if (!(--throw_cnt))
  3215.     // Looked around long enough must pass now.
  3216.             {
  3217.                 must_pass=TRUE;
  3218.                 throw_cnt=1;
  3219.             }
  3220.  
  3221.             float tx=player->tm_xdis;
  3222.             float ty=player->tm_ydis;
  3223.             player->tm_xdis=player->go_txdis;
  3224.             player->tm_ydis=player->go_tydis;
  3225.  
  3226.             float x,y,d;
  3227.  
  3228.             int p=pass_decide(player,FALSE);
  3229.             if (p)
  3230.             {
  3231.                 player->dir_mode=0;        // Face in move dir.
  3232.                 player->turn_dir=p;        // store receiver.
  3233.  
  3234.                 x=teams[p-1].tm_x-player->tm_x;
  3235.                 y=teams[p-1].tm_y-player->tm_y;
  3236.                 d=calc_dist(x,y);
  3237.                 player->go_txdis=x/d;
  3238.                 player->go_tydis=y/d;
  3239.                 player->go_tx=teams[p-1].tm_x;
  3240.                 player->go_ty=teams[p-1].tm_y;
  3241.                 already_there=FALSE;
  3242.                 stop_clock=FALSE;
  3243.  
  3244.             }
  3245.                     
  3246.             player->tm_xdis=tx;
  3247.             player->tm_ydis=ty;
  3248.         }
  3249.         else
  3250.         {
  3251. // Wait for thrower to rotate to pass direction...
  3252.             
  3253.             float ox=player->tm_xdis;
  3254.             float oy=player->tm_ydis;
  3255.  
  3256.             float dif=((player->go_txdis*ox)+(player->go_tydis*oy));
  3257.             if (ABS(dif)>0.95)
  3258.             {
  3259. // He's facing receiver...
  3260.                 make_pass(player,player->turn_dir,FALSE);
  3261.                 dead_ball_cnt=0;
  3262.                 game_action=0;
  3263.                 just_thrown=20;
  3264.                 match_mode=0;
  3265.                 launch_ball(1);            // Set up spin vector.
  3266.                 already_there=FALSE;
  3267.                 stop_clock=FALSE;
  3268.             }
  3269.         }
  3270.     }
  3271. }
  3272.  
  3273. /******************************************************************************
  3274. *****************************************************************************/
  3275.  
  3276. // Moves player on journey to target (x,y).
  3277.  
  3278. void user_run(match_player *player)
  3279. {
  3280.     float px=player->tm_x;
  3281.     float py=player->tm_y;
  3282.  
  3283.     if ((px<-(prat*2) && ux<0)
  3284.          || (px>pitch_len+(prat*2) && ux>0))
  3285.     {
  3286.         ux=0;
  3287.         if (ABS(uy)<0.05)
  3288.             init_stand_act(player);
  3289.         else
  3290.             if (uy>0)
  3291.                 uy=1;
  3292.             else
  3293.                 uy=-1;
  3294.     }
  3295.  
  3296.     if ((py<-(prat*2) && uy<0)
  3297.         || (py>pitch_wid+(prat*2) && uy>0))
  3298.     {
  3299.         uy=0;
  3300.         if (ABS(ux)<0.05)
  3301.             init_stand_act(player);
  3302.         else
  3303.             if (ux>0)
  3304.                 ux=1;
  3305.             else
  3306.                 ux=-1;
  3307.     }
  3308. /*
  3309.     if (camera==6)
  3310. // Follow mode!
  3311.     {
  3312.         float x,y;
  3313.         forward_joystick(player,x,y);
  3314.         if (uy<0)
  3315.             init_run_act(player,player->tm_x+x*256,player->tm_y+y*256,FALSE);
  3316.         else
  3317.         {
  3318.             init_stand_act(player);
  3319.             user_stand(player);
  3320.         }
  3321.     }
  3322.     else
  3323. */
  3324.         init_run_act(player,player->tm_x+ux*256,player->tm_y+uy*256,FALSE);
  3325.  
  3326.     go_forward(player);
  3327.     player->go_cnt=0;
  3328. }
  3329.  
  3330. /*****************************************************************************
  3331. *****************************************************************************/
  3332.  
  3333. // Keeper (holding ball) faces out then throws or kicks ball.
  3334.  
  3335. #define TOO_CLOSE_TO_GOAL (prat)
  3336.  
  3337. void kphold_action(match_player *player)
  3338. {
  3339.     int p=player->tm_player;
  3340.     game_action=-1;                // Force players to keep away!
  3341.  
  3342.     if (!player->int_cnt)
  3343.     {
  3344.         player->dir_mode=3;
  3345.  
  3346. // Added... Make keeper kick ball out if close to own goal line!
  3347.         char kickit=FALSE;
  3348.         if ((player->tm_player==KP_A && player->tm_x<TOO_CLOSE_TO_GOAL)
  3349.              || (player->tm_player==KP_B && player->tm_x>(pitch_len-TOO_CLOSE_TO_GOAL)))
  3350.             kickit=TRUE;
  3351.  
  3352.  
  3353.         init_anim(player,MC_STANDB);
  3354.  
  3355.         if (keep_timer)
  3356.             keep_timer--;
  3357.  
  3358.         if (!opp_around(ballx,bally,player->tm_player) || !keep_timer)
  3359.         {
  3360. // No opposition near!
  3361.             if (seed&1 && seed&8 && !kickit)
  3362.             {
  3363. // Bounce the ball...
  3364.                   init_anim(player,MC_BOUNCE);
  3365.                 player->int_move=I_KP_BUSY;
  3366.                 player->int_cnt=(1./MC_BOUNCE_FS);
  3367.             }
  3368.             else
  3369.             {
  3370.                 if (seed&2 && seed&8 && !kickit)
  3371.                 {
  3372. // Wave team-mates up-field...
  3373.                       init_anim(player,MC_WAVEUP);
  3374.                     player->int_move=I_KP_BUSY;
  3375.                     player->int_cnt=(1./MC_WAVEUP_FS);
  3376.                 }
  3377.                 else
  3378.                 {
  3379.                     if (seed&4 && seed&8 && !kickit)
  3380.                     {
  3381. // Stand for a bit...
  3382.                         player->int_move=I_KP_BUSY;
  3383.                         player->int_cnt=20;
  3384.                     }
  3385.                     else
  3386.                     {
  3387. // Just run...
  3388.                         if ((p==KP_A) && (player->tm_xdis>=0.95))
  3389.                         {
  3390.                             init_run_act(player,player->tm_x+(prat*15),player->tm_y,FALSE);
  3391.                         }
  3392.  
  3393.                         if ((p==KP_B) && (player->tm_xdis<=-0.95))
  3394.                         {
  3395.                             init_run_act(player,player->tm_x-(prat*15),player->tm_y,FALSE);
  3396.                         }
  3397.  
  3398.                         if (ABS(player->tm_anim)==MC_RUN)
  3399.                               init_anim(player,MC_RUNWITHB);
  3400.                     }
  3401.                 }
  3402.             }
  3403.         }
  3404.     }
  3405. }
  3406.  
  3407. /******************************************************************************
  3408. *****************************************************************************/
  3409.  
  3410. void wait_action(match_player *player)
  3411. {
  3412.     if    ((player->ball_state<0 && !ball_poss)
  3413.          || (player->ball_state>0 && player->ball_state!=last_touch))
  3414. // Ball has changed trajectory!
  3415.         init_stand_act(player);
  3416.     else
  3417.     {
  3418.         if (!(--player->tm_ftime))
  3419. // No more waiting!
  3420.         {
  3421.             player->tm_strike=-player->tm_strike;
  3422.             init_strike_act(player);
  3423.         }
  3424.         else
  3425.         {
  3426.             player->tm_x+=player->go_txdis;
  3427.             player->tm_y+=player->go_tydis;
  3428.         }
  3429.     }
  3430. }
  3431.  
  3432. /******************************************************************************
  3433. *****************************************************************************/
  3434.  
  3435. void stop_action(match_player *player)
  3436. {
  3437.     if (player->int_move==I_INTERCEPT)
  3438.     {
  3439.         float    a=angle_to_xy(player->go_xoff,player->go_yoff,player->tm_xdis,player->tm_ydis);
  3440.  
  3441.         if (a>cos(MAX_TURN))
  3442.         {
  3443. // Facing target now...
  3444.             init_run_act(player,player->go_tx,player->go_ty,FALSE);
  3445.             go_toward_target(player);
  3446.         }
  3447.     }
  3448.     else
  3449.         init_stand_act(player);
  3450. }
  3451.  
  3452. /******************************************************************************
  3453. *****************************************************************************/
  3454.  
  3455. void init_stop_act(match_player *player,float x,float y)
  3456. {
  3457.     player->dir_mode=0;
  3458.     player->tm_act=STOP_ACT;
  3459.     player->go_tx=x;
  3460.     player->go_ty=y;
  3461.     player->go_xoff=x-player->tm_x;
  3462.     player->go_yoff=y-player->tm_y;
  3463.     init_anim(player,MC_STAND);
  3464. }
  3465.      
  3466. /******************************************************************************
  3467. *****************************************************************************/
  3468.  
  3469. void init_wait_act(match_player *player,float x,float y)
  3470. {
  3471.     player->dir_mode=2;
  3472.     player->tm_act=WAIT_ACT;
  3473.     player->go_step=TRUE;    // Side step if needed!
  3474.     short m=player->int_move;
  3475.     player->int_move=0;
  3476.     float rate=actual_spd(player);
  3477.     player->int_move=m;
  3478.  
  3479.     float d=calc_dist(x,y);
  3480.     x=x/d;
  3481.     y=y/d;
  3482.     short t=player->tm_ftime;
  3483.  
  3484.     d=d/t;        // Magnitude of displacement!
  3485.     if (d>(rate+(player->tm_stime-1)))
  3486.         init_stand_act(player);
  3487.     else
  3488.     {
  3489.         player->tm_strike=-player->tm_strike;
  3490.         player->go_txdis=x*d;
  3491.         player->go_tydis=y*d;
  3492. //        player->go_tx=player->go_tx-player->tm_x+(player->go_txdis*(t+1));
  3493. //        player->go_ty=player->go_ty-player->tm_y+(player->go_tydis*(t+1));
  3494.         if (d>.5)
  3495.             init_anim(player,MC_TROTA);
  3496.         else
  3497.             init_anim(player,MC_STAND);
  3498.         player->int_cnt=player->tm_ftime+1;
  3499.  
  3500.         player->tm_x+=player->go_txdis;
  3501.         player->tm_y+=player->go_tydis;
  3502.     }
  3503. }
  3504.  
  3505. /******************************************************************************
  3506. *****************************************************************************/
  3507.  
  3508. void control_action(match_player *player)
  3509. {
  3510.     if (player->tm_frm>=1)
  3511.     {
  3512. // end of animation...
  3513.         ballz=0;
  3514.         init_stand_act(player);
  3515.         player->tm_ftime=-2;
  3516.         hold_ball(player);
  3517.         ball_limbo_on=FALSE;
  3518.     }
  3519.     else
  3520.     {
  3521.         if (player->tm_frm>=player->contact && ball_poss!=player->tm_player && player->tm_ftime>=0)
  3522. // Player should have ball now but doesn't....
  3523.         {
  3524.             init_stand_act(player);
  3525.         }
  3526.         else
  3527.         {
  3528.             player->tm_x+=player->go_txdis;
  3529.             player->tm_y+=player->go_tydis;
  3530.         }
  3531.     }
  3532. }
  3533.  
  3534. /******************************************************************************
  3535. *****************************************************************************/
  3536.  
  3537. void get_closest_pred(match_player *player,float &rt,float &x,float &y,float &z,float &d)
  3538. {
  3539.     float sx,sy,sz;
  3540.     rotate_offs(player->tm_anim,sx,sy,sz,player->mface_x,player->mface_y);
  3541.  
  3542.     x=ball_pred_tab[(int)(rt)][0]-sx;
  3543.     y=ball_pred_tab[(int)(rt)][1]-sy;
  3544.     z=ball_pred_tab[(int)(rt)][2]-sz;
  3545.  
  3546.     x=x-player->tm_x;
  3547.     y=y-player->tm_y;
  3548.     z=z-player->tm_z;
  3549.  
  3550.     d=calc_dist(x,y);
  3551.     d=calc_dist(z,d);
  3552.  
  3553.     float best_rt=rt;
  3554.     float min_d=d;
  3555.     float best_x=x;
  3556.     float best_y=y;
  3557.     float best_z=z;
  3558.  
  3559. // Check one forward...
  3560.     if (rt<49)
  3561.     {
  3562.         rt++;
  3563.         x=ball_pred_tab[(int)(rt)][0]-sx;
  3564.         y=ball_pred_tab[(int)(rt)][1]-sy;
  3565.         z=ball_pred_tab[(int)(rt)][2]-sz;
  3566.  
  3567.         x=x-player->tm_x;
  3568.         y=y-player->tm_y;
  3569.         z=z-player->tm_z;
  3570.  
  3571.         d=calc_dist(x,y);
  3572.         d=calc_dist(z,d);
  3573.  
  3574.         if (d<min_d)
  3575.         {
  3576.             min_d=d;
  3577.             best_rt=rt;
  3578.             best_x=x;
  3579.             best_y=y;
  3580.             best_z=z;
  3581.         }
  3582.     }
  3583.  
  3584. // Check one back...
  3585.     if (rt>=1)
  3586.     {
  3587.         rt-=2;
  3588.         x=ball_pred_tab[(int)(rt)][0]-sx;
  3589.         y=ball_pred_tab[(int)(rt)][1]-sy;
  3590.         z=ball_pred_tab[(int)(rt)][2]-sz;
  3591.  
  3592.         x=x-player->tm_x;
  3593.         y=y-player->tm_y;
  3594.         z=z-player->tm_z;
  3595.  
  3596.         d=calc_dist(x,y);
  3597.         d=calc_dist(z,d);
  3598.  
  3599.         if (d<min_d)
  3600.         {
  3601.             min_d=d;
  3602.             best_rt=rt;
  3603.             best_x=x;
  3604.             best_y=y;
  3605.             best_z=z;
  3606.         }
  3607.     }
  3608.  
  3609.     d=min_d;
  3610.     x=best_x;
  3611.     y=best_y;
  3612.     z=best_z;
  3613.     rt=best_rt;
  3614. }
  3615.  
  3616. /******************************************************************************
  3617. *****************************************************************************/
  3618.  
  3619. void init_control_act(match_player *player)
  3620. {
  3621.     float x,y,z,d,rt;
  3622.  
  3623.     switch(player->tm_strike)
  3624.     {
  3625.         case(1):
  3626.             init_anim(player,MC_TRAPL);
  3627.             player->contact=MCC_TRAP;
  3628.             z=save_offs[(MC_TRAPL*3)+2];
  3629.             break;
  3630.  
  3631.         case(2):
  3632.             init_anim(player,MC_CHEST);
  3633.             player->contact=MCC_CHEST;
  3634.             z=save_offs[(MC_CHEST*3)+2];
  3635.             break;
  3636.  
  3637.         case(3):
  3638.             init_anim(player,MC_D_HEAD);
  3639.             player->contact=MCC_D_HEAD;
  3640.             z=save_offs[(MC_D_HEAD*3)+2];
  3641.             break;
  3642.     }
  3643.     
  3644. // Real contact point with offset...
  3645.     float old_rt=player->tm_stime+player->tm_ftime;
  3646.     rt=old_rt;
  3647.     get_closest_pred(player,rt,x,y,z,d);
  3648.  
  3649.     player->tm_ftime+=rt-old_rt;        // Add difference in timing.
  3650.  
  3651.     if (player->tm_ftime>0)
  3652.     {
  3653. // Some free time... (lets stand and wait!)
  3654.         init_wait_act(player,x,y);
  3655.     }
  3656.     else
  3657.     {
  3658. // Need to run animation...
  3659.         player->tm_ftime=0;
  3660.         short ts=player->tm_strike;
  3661.         reset_ideas(player);
  3662.  
  3663.         if (player->tm_player>11)
  3664.             interceptor_b=player->tm_player;
  3665.         else
  3666.             interceptor_a=player->tm_player;
  3667.  
  3668.         player->tm_strike=ts;
  3669.         player->tm_act=CONTROL_ACT;
  3670.         player->int_move=I_RECEIVE;
  3671.         player->tm_fstep=player->contact/rt;
  3672.         player->tm_frm=player->tm_fstep+0.01;
  3673.         player->int_cnt=((1.0-player->tm_frm)/player->tm_fstep)+1;
  3674.     
  3675.         d=calc_dist(x,y);
  3676.         if (d/rt>1)
  3677. // Ball has changed direction... (cannot meet!)
  3678.             init_stand_act(player);
  3679.         else
  3680.         {
  3681.             if (abs(z)>prat)
  3682. // Ball has changed direction... (cannot meet!)
  3683.                 init_stand_act(player);
  3684.             else
  3685.             {
  3686. // set displacement to meet ball at contact point!
  3687.                 player->go_txdis=x/rt;
  3688.                 player->go_tydis=y/rt;
  3689.  
  3690. // keep facing same direction!
  3691.                 player->dir_mode=2;
  3692.             }
  3693.  
  3694.             player->tm_strike=-player->tm_strike;
  3695.         }
  3696.     }
  3697. }
  3698.  
  3699. /******************************************************************************
  3700. *****************************************************************************/
  3701.  
  3702. #define JUMP_POINT (0.1)
  3703.  
  3704. void strike_action(match_player *player)
  3705. {
  3706.     if (player->tm_frm+player->tm_fstep>=1)
  3707.     {
  3708. // end of animation...
  3709.         player->tm_ftime=-2;
  3710.  
  3711.         if (player->tm_anim==MC_OVERHEAD)
  3712.         {
  3713. // On the ground must get up ( on his back )...
  3714.             player->tm_limbo=1/MC_GETUP_FS;
  3715.             init_anim(player,MC_GETUP);
  3716.         }
  3717.         else
  3718.         {
  3719.             if (player->tm_anim==MC_DV_HEAD)
  3720.             {
  3721. // On the ground must get up ( on his front )...
  3722.                 player->tm_limbo=1/MC_GETUPF_FS;
  3723.                 init_anim(player,MC_GETUPF);
  3724.             }
  3725.             else
  3726.                 init_stand_act(player);
  3727.         }
  3728.     }
  3729.     else
  3730.     {
  3731.         if (player->tm_anim==MC_J_HEAD)
  3732.         {
  3733. // Jumping header...
  3734.             if (player->tm_frm>JUMP_POINT)
  3735.             {
  3736.                 player->tm_z+=player->tm_zdis;
  3737.                 if (player->tm_z<0)
  3738.                     player->tm_z=0;
  3739.                 else
  3740.                     player->tm_zdis-=gravity;
  3741.             }
  3742.         }
  3743.  
  3744.         if (player->tm_frm>=player->contact)
  3745. // Player can slow down now...
  3746.         {
  3747.             player->go_txdis=player->go_txdis*SAVE_DECEL;
  3748.             player->go_tydis=player->go_tydis*SAVE_DECEL;
  3749.         }
  3750.  
  3751.         player->tm_x+=player->go_txdis;
  3752.         player->tm_y+=player->go_tydis;
  3753.     }
  3754. }
  3755.  
  3756. /******************************************************************************
  3757. *****************************************************************************/
  3758.  
  3759. void init_first_time_act(match_player *player,int mc,float pc)
  3760. {
  3761.     float x,y,z,d,rt;
  3762.  
  3763.     init_anim(player,mc);
  3764.  
  3765.     player->tm_frm=0;
  3766.     
  3767. // Real contact point with offset...
  3768.     float old_rt=player->tm_stime+player->tm_ftime;
  3769.     rt=old_rt;
  3770.     get_closest_pred(player,rt,x,y,z,d);
  3771.  
  3772.     player->tm_ftime+=rt-old_rt;        // Add difference in timing.
  3773.  
  3774.     if (player->tm_ftime>0)
  3775.     {
  3776. // Some free time... (lets stand and wait!)
  3777.         init_wait_act(player,x,y);
  3778.     }
  3779.     else
  3780.     {
  3781. // Need to speed up animation...
  3782.         player->tm_ftime=0;
  3783.         short ts=player->tm_strike;
  3784.         reset_ideas(player);            // Stop interception etc.
  3785.  
  3786.         if (player->tm_player>11)
  3787.             interceptor_b=player->tm_player;
  3788.         else
  3789.             interceptor_a=player->tm_player;
  3790.  
  3791.         player->tm_strike=ts;
  3792.         player->tm_act=STRIKE_ACT;
  3793.         player->int_move=I_RECEIVE;
  3794.         player->contact=pc;
  3795.         float fs=player->tm_fstep;
  3796.         player->tm_fstep=player->contact/rt;
  3797.         player->tm_frm=player->tm_fstep+0.01;
  3798.         player->int_cnt=((1.0-player->tm_frm)/player->tm_fstep)+1;
  3799.  
  3800.         if (mc==MC_J_HEAD)
  3801.             player->tm_zdis=(gravity*((player->int_cnt-1)*.6)/2);
  3802.  
  3803.         d=calc_dist(x,y);
  3804.         if (d/rt>2)
  3805. // Ball has changed direction... (cannot meet!)
  3806.             init_stand_act(player);
  3807.         else
  3808.         {
  3809.             if (abs(z)>prat)
  3810. // Ball has changed direction... (cannot meet!)
  3811.                 init_stand_act(player);
  3812.             else
  3813.             {
  3814.  
  3815. // set displacement to meet ball at contact point!
  3816.                 player->go_txdis=x/rt;
  3817.                 player->go_tydis=y/rt;
  3818.  
  3819. // keep facing same direction!
  3820.                 player->dir_mode=2;
  3821.             }
  3822.             player->tm_strike=-player->tm_strike;
  3823.         }
  3824.     }
  3825. }
  3826.  
  3827. /******************************************************************************
  3828. *****************************************************************************/
  3829.  
  3830. void oinit_first_time_act(match_player *player,int mc,float pc)
  3831. {
  3832.     float x,y,z,d;
  3833.  
  3834.     init_anim(player,mc);
  3835.  
  3836.     float sx,sy,sz;
  3837.  
  3838.     rotate_offs(mc,sx,sy,sz,player->tm_xdis,player->tm_ydis);
  3839.  
  3840. // Real contact point with offset...
  3841.     float rt=player->tm_stime+player->tm_ftime;
  3842.     x=ball_pred_tab[(int)(rt)][0]-sx;
  3843.     y=ball_pred_tab[(int)(rt)][1]-sy;
  3844.     z=ball_pred_tab[(int)(rt)][2]-sz;
  3845.  
  3846.     x=x-player->tm_x;
  3847.     y=y-player->tm_y;
  3848.     z=z-player->tm_z;
  3849.  
  3850.     if (player->tm_ftime)
  3851.     {
  3852. // Some free time... (lets stand and wait!)
  3853.         init_wait_act(player,x,y);
  3854.     }
  3855.     else
  3856.     {
  3857.         player->tm_strike=-player->tm_strike;
  3858.         float fs=player->tm_fstep;        // Standard anim speed fstep!
  3859.         player->contact=pc;
  3860.         player->tm_fstep=(pc-player->tm_frm)/(player->tm_stime+player->tm_ftime);
  3861.         player->dir_mode=2;
  3862.         reset_ideas(player);            // Stop interception etc.
  3863.         player->int_move=I_RECEIVE;
  3864.         player->int_cnt=((pc-player->tm_frm)/player->tm_fstep)+(1-pc/fs)+1;
  3865.         player->tm_act=STRIKE_ACT;
  3866.  
  3867.         float d=calc_dist(x,y);
  3868.         if (d/rt>1)
  3869.     // Ball has changed direction... (cannot meet!)
  3870.             init_stand_act(player);
  3871.         else
  3872.         {
  3873.             if (abs(z)>prat)
  3874.     // Ball has changed direction... (cannot meet!)
  3875.                 init_stand_act(player);
  3876.             else
  3877.             {
  3878.     // set displacement to meet ball at contact point!
  3879.                 player->go_txdis=x/rt;
  3880.                 player->go_tydis=y/rt;
  3881.             }
  3882.         }
  3883.     }
  3884. }
  3885.  
  3886. /******************************************************************************
  3887. *****************************************************************************/
  3888.  
  3889. void init_strike_act(match_player *player)
  3890. {
  3891.     short s;
  3892.  
  3893.     switch(player->tm_strike)
  3894.     {
  3895.         case(1):
  3896.         case(2):
  3897.         case(3):
  3898.             init_control_act(player);
  3899.             break;
  3900.  
  3901.         case(4):
  3902.             init_first_time_act(player,MC_OVERHEAD,MCC_OVERHEAD);
  3903.             headed_ball=FALSE;
  3904.             break;
  3905.  
  3906.         case(5):
  3907.             init_first_time_act(player,MC_VOLLEYL,MCC_VOLLEY);
  3908.             headed_ball=FALSE;
  3909.             break;
  3910.  
  3911.         case(6):
  3912.             init_first_time_act(player,MC_DV_HEAD,MCC_DV_HEAD);
  3913.             headed_ball=TRUE;
  3914.             break;
  3915.  
  3916.         case(7):
  3917.             init_first_time_act(player,MC_J_HEAD,MCC_J_HEAD);
  3918.             headed_ball=TRUE;
  3919.             break;
  3920.  
  3921.         case(8):
  3922.             init_first_time_act(player,MC_SHOOTL,MCC_SHOOT);
  3923.             headed_ball=FALSE;
  3924.             break;
  3925.  
  3926.         case(9):
  3927.             init_first_time_act(player,MC_S_HEAD,MCC_S_HEAD);
  3928.             headed_ball=TRUE;
  3929.             break;
  3930.  
  3931.         case(10):
  3932.             init_first_time_act(player,MC_CHIPL,MCC_CHIP);
  3933.             headed_ball=FALSE;
  3934.             break;
  3935.     }
  3936. }
  3937.  
  3938. /******************************************************************************
  3939. *****************************************************************************/
  3940.  
  3941. // Moves player on journey to target (x,y).
  3942.  
  3943. void orun_action(match_player *player)
  3944. {
  3945.     if ((player->tm_comm==SAY_PASS || player->tm_comm==SAY_CROSS)
  3946.         && !player->tm_ccnt)
  3947. // He's asking for ball!
  3948.         go_toward_target(player);
  3949.     else
  3950.     {
  3951.         int player_ref=player->tm_player;
  3952.  
  3953.         if ((ball_poss || (!ball_poss && player->int_move!=I_INTERCEPT)) && (user_controlled) && (!match_mode))
  3954.  
  3955.             user_run(player);
  3956.         else
  3957.         {
  3958.             if (ball_poss!=player_ref)
  3959.             {
  3960.                 if (sender_1_2!=player_ref)
  3961.                 {
  3962.                     if (player->tm_strike>0 && player->int_move==I_INTERCEPT
  3963.                          && ((player->ball_state<0 && !ball_poss)
  3964.                          || (player->ball_state>0 && player->ball_state!=last_touch)))
  3965.                          init_stand_act(player);
  3966.                     else
  3967.                     {
  3968.                         --player->go_cnt;
  3969.                         if (player->go_cnt<=0)
  3970.                         {
  3971.                             player->go_cnt=0;
  3972.  
  3973.                             if (player->tm_strike>0 && player->int_move==I_INTERCEPT)
  3974. // Begin first touch animation...
  3975.                             {
  3976.                                 go_toward_target(player);
  3977.                                 init_strike_act(player);
  3978.                             }
  3979.                             else
  3980.                             {
  3981.                                 if ((player->tm_player==KP_A && !(ballx<cntspot_x && shot_pending))
  3982.                                     || (player->tm_player==KP_B && !(ballx>cntspot_x && shot_pending))
  3983.                                     || (player->tm_player!=KP_A && player->tm_player!=KP_B))
  3984.                                 {
  3985. // Make sure that keeper isn't waiting to make save!
  3986.                                     find_zonal_target(player,player->tm_x,player->tm_y);    //players x,y for comparison.
  3987.                                     if ((player->go_cnt) && (player->tm_act==RUN_ACT))
  3988.                                     {
  3989.                                         go_toward_target(player);
  3990.                                     }
  3991.                                     else
  3992.                                     {
  3993.                                         if (player->tm_act!=TURN_ACT)
  3994.                                             init_stand_act(player);
  3995.                                     }
  3996.                                 }
  3997.                                 else
  3998.                                 {
  3999. // Keeper waiting to make save!
  4000.                                     init_stand_act(player);
  4001.                                 }
  4002.                             }
  4003.                         }
  4004.                         else
  4005.                         {
  4006.                             if (just_scored>0)
  4007.                                 someone_has_scored(player);        // Target is goal scorer!
  4008.                             else                    
  4009.                             {
  4010.                                 go_toward_target(player);
  4011.                             }
  4012.                         }
  4013.                     }
  4014.                 }
  4015.             }
  4016.             else
  4017. // Running with ball!
  4018.             {
  4019.                 --player->go_cnt;
  4020.                 if (player->go_cnt<=0)
  4021.                 {
  4022.                     player->go_cnt=0;
  4023.                     init_stand_act(player);
  4024.                 }
  4025.                 else
  4026.                 {
  4027.                     go_toward_target(player);
  4028.                     if (ball_in_hands)
  4029.                     {
  4030.                         if (player->tm_player==KP_A)
  4031.                         {
  4032. // Keeper A...
  4033.                             if (keeper_a_in_box)
  4034.                             {
  4035. // Can only take three steps...
  4036.                                 if (!(--keeper_steps))
  4037.                                     must_punt=TRUE;
  4038.                             }
  4039.                             else
  4040.                             {
  4041.                                 must_punt=TRUE;
  4042.                             }
  4043.                         }
  4044.                          else
  4045.                         {
  4046.                             if (player->tm_player==KP_B)
  4047. // Keeper B...
  4048.                             {
  4049.                                 if (keeper_b_in_box)
  4050.                                 {
  4051.                                     if (!(--keeper_steps))
  4052.                                         must_punt=TRUE;
  4053. // Can only take three steps...
  4054.                                 }
  4055.                                 else
  4056.                                 {
  4057.                                     must_punt=TRUE;
  4058.                                 }
  4059.                             }
  4060.                         }
  4061.                     }
  4062.                 }
  4063.             }
  4064.         }
  4065.     }
  4066. }
  4067.  
  4068.  
  4069. /******************************************************************************
  4070. *****************************************************************************/
  4071.  
  4072. // Moves player on journey to target (x,y).
  4073.  
  4074. void run_action(match_player *player)
  4075. {
  4076.     if ((player->tm_comm==SAY_PASS || player->tm_comm==SAY_CROSS)
  4077.         && !player->tm_ccnt)
  4078. // He's asking for ball!
  4079.         go_forward(player);
  4080.     else
  4081.     {
  4082.         int player_ref=player->tm_player;
  4083.  
  4084.         if (user_controlled && game_action!=-1 && !match_mode && (ball_poss || (!ball_poss && player->int_move!=I_INTERCEPT)))
  4085.  
  4086.             user_run(player);
  4087.         else
  4088.         {
  4089.             if (ball_poss!=player_ref)
  4090.             {
  4091. // Doesn't have ball...
  4092.                 if (sender_1_2!=player_ref)
  4093.                 {
  4094. // Not part of 1-2 move...
  4095.                     if (player->tm_strike>0 && player->int_move==I_INTERCEPT
  4096.                          && ((player->ball_state<0 && !ball_poss)
  4097.                          || (player->ball_state>0 && player->ball_state!=last_touch)))
  4098.  
  4099. // Can't continue first touch action! (Ball trajectory has changed!)
  4100.  
  4101.                          init_stand_act(player);
  4102.                     else
  4103.                     {
  4104.                         if (user_controlled && player->int_move==I_INTERCEPT && player->int_cnt
  4105.                              && !player->tm_strike && (uf1 || uf2))
  4106.                              go_to_path(player->tm_player);        // Forced to try special move next cycle...
  4107.  
  4108.                         if (player->go_cnt && player->dir_mode!=6)
  4109.                             go_forward(player);
  4110.  
  4111.                         if (player->tm_trap && player_ref==player_on_off
  4112.                              && player->go_cnt<12)
  4113.                             player->draw_me=FALSE;
  4114.  
  4115.                         --player->go_cnt;
  4116.                         if (player->go_cnt<=0)
  4117.                         {
  4118. // Should be at target now!
  4119.                             player->go_cnt=0;
  4120.  
  4121.                               if (player->int_move==I_CELEB)
  4122.                               {
  4123. // Celebration run finished...
  4124.                                   init_taunt_act(player);
  4125.                               }
  4126.                                 
  4127.                             if (player->tm_strike>0 && player->int_move==I_INTERCEPT)
  4128. // Begin first touch animation...
  4129.                             {
  4130.                                 if (player->mface && player->dir_mode!=6)
  4131.                                 {
  4132.                                     player->dir_mode=6;
  4133.                                     player->go_cnt=player->mface_time;
  4134.                                     init_anim(player,MC_STAND);
  4135.                                 }
  4136.                                 else
  4137.                                     init_strike_act(player);
  4138.                             }
  4139.                             else
  4140.                             {
  4141.                                 if ((player->tm_player==KP_A && !(ballx<cntspot_x && shot_pending))
  4142.                                     || (player->tm_player==KP_B && !(ballx>cntspot_x && shot_pending))
  4143.                                     || (player->tm_player!=KP_A && player->tm_player!=KP_B))
  4144.                                 {
  4145. // Make sure that keeper isn't waiting to make save!
  4146.                                     if (just_scored)
  4147.                                         someone_has_scored(player);
  4148.                                     else
  4149.                                         if (player->int_move==I_OFF)
  4150.                                         {
  4151.                                             player->tm_x=player->go_tx;
  4152.                                             player->tm_y=player->go_ty;
  4153.                                             init_stand_act(player);
  4154.                                         }
  4155.                                         else
  4156.                                         {
  4157.                                             if (player->int_cnt)
  4158.                                                 init_stand_act(player);
  4159.                                             else
  4160.                                                 find_zonal_target(player,player->tm_x,player->tm_y);    //players x,y for comparison.
  4161.     
  4162.                                                 }
  4163.                                 }
  4164.                                 else
  4165.                                 {
  4166. // Keeper waiting to make save!
  4167.                                     init_stand_act(player);
  4168.                                 }
  4169.                             }
  4170.                         }
  4171.                         else
  4172.                         {
  4173.                             if (just_scored>0 && player->int_move!=I_CELEB)
  4174.                                 someone_has_scored(player);        // Target is goal scorer!
  4175.                         }
  4176.                     }
  4177.                 }
  4178.             }
  4179.             else
  4180. // Running with ball!
  4181.             {
  4182.                 if (player->go_cnt)
  4183.                     go_forward(player);
  4184.  
  4185.                 --player->go_cnt;
  4186.                 if (player->go_cnt<=0)
  4187.                 {
  4188.                     player->go_cnt=0;
  4189.                     init_stand_act(player);
  4190.                 }
  4191.                 else
  4192.                 {
  4193.                     if (ball_in_hands)
  4194.                     {
  4195.                         if (player->tm_player==KP_A)
  4196.                         {
  4197. // Keeper A...
  4198.                             if (keeper_a_in_box)
  4199.                             {
  4200. // Can only take three steps...
  4201.                                 if (!(--keeper_steps))
  4202.                                 {
  4203.                                     game_action=0;
  4204.                                     must_punt=TRUE;
  4205.                                 }
  4206.                             }
  4207.                             else
  4208.                             {
  4209.                                 game_action=0;
  4210.                                 must_punt=TRUE;
  4211.                             }
  4212.                         }
  4213.                          else
  4214.                         {
  4215.                             if (player->tm_player==KP_B)
  4216. // Keeper B...
  4217.                             {
  4218.                                 if (keeper_b_in_box)
  4219.                                 {
  4220.                                     if (!(--keeper_steps))
  4221.                                     {
  4222.                                         game_action=0;
  4223.                                         must_punt=TRUE;
  4224.                                     }
  4225. // Can only take three steps...
  4226.                                 }
  4227.                                 else
  4228.                                 {
  4229.                                     game_action=0;
  4230.                                     must_punt=TRUE;
  4231.                                 }
  4232.                             }
  4233.                         }
  4234.                     }
  4235.                 }
  4236.             }
  4237.         }
  4238.     }
  4239. }
  4240.  
  4241. /******************************************************************************
  4242. *****************************************************************************/
  4243.  
  4244. void tackle_action(match_player *player)
  4245. {
  4246.     go_toward_target(player);
  4247.     player->go_txdis*=TACKLE_DECEL;
  4248.     player->go_tydis*=TACKLE_DECEL;
  4249.     if (!player->go_cnt--)
  4250.         init_stand_act(player);
  4251. }
  4252.  
  4253. /******************************************************************************
  4254. *****************************************************************************/
  4255.  
  4256. void save_action(match_player *player)
  4257. {
  4258.     if ((player->tm_player==KP_A && keeper_a_in_box)
  4259.         || (player->tm_player==KP_B && keeper_b_in_box))
  4260.     {
  4261.         player->tm_x+=player->go_txdis;
  4262.         player->tm_y+=player->go_tydis;
  4263.     }
  4264.     else
  4265.     {
  4266.         seconds++;
  4267.     }
  4268.  
  4269.     if (player->tm_anim>=MC_AFOOTB && player->tm_anim<=MC_AJUMPC && player->tm_frm>keeper_contact)
  4270.     {
  4271. // Slow him down after ball contact in zone A...
  4272.         player->go_txdis=player->go_txdis*SAVE_DECEL;
  4273.         player->go_tydis=player->go_tydis*SAVE_DECEL;
  4274.     }
  4275.  
  4276. /*WAIT for mcap data*/
  4277. /* If keeper lands on ground slow him down...*/
  4278.  
  4279.     if (!player->go_cnt--)
  4280.     {
  4281.         player->go_txdis=player->go_txdis*SAVE_DECEL;
  4282.         player->go_tydis=player->go_tydis*SAVE_DECEL;
  4283.         player->go_cnt=0;
  4284.         player->tm_fstep=0;
  4285.         player->tm_frm=.9999;
  4286.         if ((!keeper_on_grnd) || (keeper_on_grnd && player->int_cnt<=1))
  4287.         {
  4288.             shot_acknowledged=FALSE;
  4289.             player->go_cnt=0;
  4290.             init_stand_act(player);
  4291.         }
  4292.     }
  4293. }
  4294.  
  4295. /******************************************************************************
  4296. *****************************************************************************/
  4297.  
  4298. void fall_action(match_player *player)
  4299. {
  4300.     go_toward_target(player);
  4301.     player->go_txdis*=TACKLE_DECEL;
  4302.     player->go_tydis*=TACKLE_DECEL;
  4303.     player->go_cnt--;
  4304.  
  4305.     if (player->go_cnt==1)
  4306.     {
  4307.         init_anim(player,MC_GETUPF);
  4308.         player->tm_fstep*=((float)(player->tm_rate+128)/128);
  4309.         player->tm_limbo=1/player->tm_fstep;
  4310.     }
  4311.     else
  4312.         if (!player->go_cnt)
  4313.             init_stand_act(player);
  4314. }
  4315.  
  4316. /******************************************************************************
  4317. *****************************************************************************/
  4318.  
  4319. void init_tussles()
  4320. {
  4321.     tussle_ptr=&tussle_tab[0];
  4322.     *tussle_ptr=0;
  4323. }
  4324.  
  4325. /******************************************************************************
  4326. *****************************************************************************/
  4327.  
  4328. void tussle_collision(match_player *p1,match_player *p2)
  4329. {
  4330.     float xoff,yoff,dist;
  4331.  
  4332.     xoff=(p2->tm_x)-(p1->tm_x);
  4333.     yoff=(p2->tm_y)-(p1->tm_y);
  4334.  
  4335.     dist=calc_dist(xoff,yoff);
  4336.  
  4337.     if (dist<prat*0.7)
  4338.     {
  4339.  
  4340. // Sub vectors to get force of collision!
  4341.         float ef_xd=((p1->tm_pow*p1->go_txdis)-(p2->tm_pow*p2->go_txdis));
  4342.         float ef_yd=((p1->tm_pow*p1->go_tydis)-(p2->tm_pow*p2->go_tydis));
  4343.         int force=ABS(ef_xd)+ABS(ef_yd);
  4344.         
  4345. // Add averaged vector!
  4346.         ef_xd=(p1->go_txdis)+(p2->go_txdis);
  4347.         ef_yd=(p1->go_tydis)+(p2->go_tydis);
  4348.         int power=(p1->tm_pow+(p1->tm_act==STEAL_ACT ? 32:0)+(p1->tm_act==SAVE_ACT ? 500:0))
  4349.                      -(p2->tm_pow+(p2->tm_act==STEAL_ACT ? 32:0)+(p2->tm_act==SAVE_ACT ? 500:0));
  4350.  
  4351.         if (power+(seed/2)-32<0)
  4352. // Player 1 is shoved!
  4353.         {
  4354.             if (p2->tm_anim==MC_RUN)
  4355.             {
  4356. // Player 2 can barge run!
  4357.                 init_anim(p2,MC_BARGE);
  4358.                 p2->tm_barge=20;
  4359.             }
  4360.  
  4361.             if (p2->tm_player==KP_B)
  4362.                 force*=2;
  4363.  
  4364.             if (p2->tm_act==SAVE_ACT)
  4365.                 force+=128*16;
  4366.  
  4367. // Update current movement!
  4368.             if (force/16>seed && (!(seed&3) || p2->tm_act==SAVE_ACT))
  4369.             {
  4370.                 float d=calc_dist(ef_xd,ef_yd);
  4371.                 p1->tm_xdis=ef_xd/d;
  4372.                 p1->tm_ydis=ef_yd/d;
  4373.                 init_fall(p1);
  4374.                 if (p2->tm_act==SAVE_ACT && (p2->tm_poss+2)*32<((float)seed*ref_strictness/128))
  4375.                 {
  4376.                     man_down=TRUE;
  4377.                     init_foul(p2->tm_player,TRUE);    // pass no. of fouler.
  4378.                 }
  4379.                 else
  4380.                 {
  4381.                     p1->tm_x+=(ef_xd);
  4382.                     p1->tm_y+=(ef_yd);
  4383.  
  4384.                     if ((p1->tm_act==RUN_ACT) || (p1->tm_act==JUMP_ACT))
  4385.                     {
  4386.                         p1->tm_x-=(p1->go_txdis);
  4387.                         p1->tm_y-=(p1->go_tydis);
  4388.                     }
  4389.                 }
  4390.             }
  4391.             else
  4392.             {
  4393.                 p1->tm_x+=(ef_xd);
  4394.                 p1->tm_y+=(ef_yd);
  4395.  
  4396.                 if ((p1->tm_act==RUN_ACT) || (p1->tm_act==JUMP_ACT))
  4397.                 {
  4398.                     p1->tm_x-=(p1->go_txdis);
  4399.                     p1->tm_y-=(p1->go_tydis);
  4400.                 }
  4401.             }
  4402.         }
  4403.         else
  4404. // Player 2 is shoved!
  4405.         {
  4406.             if (p1->tm_anim==MC_RUN)
  4407.             {
  4408. // Player 1 can barge run!
  4409.                 init_anim(p1,MC_BARGE);
  4410.                 p1->tm_barge=20;
  4411.             }
  4412.  
  4413. // Update current movement!
  4414.             if (force/16>seed && (!(seed&3) || p2->tm_act==SAVE_ACT))
  4415.             {
  4416.                 float d=calc_dist(ef_xd,ef_yd);
  4417.                 p2->tm_xdis=ef_xd/d;
  4418.                 p2->tm_ydis=ef_yd/d;
  4419.                 init_fall(p2);
  4420.                 if (p1->tm_act==SAVE_ACT && (p1->tm_poss+2)*32<((float)seed*ref_strictness/128))
  4421.                 {
  4422.                     man_down=TRUE;
  4423.                     init_foul(p1->tm_player,TRUE);    // pass no. of fouler.
  4424.                 }
  4425.             }
  4426.             else
  4427.             {
  4428.                 p2->tm_x+=(ef_xd);
  4429.                 p2->tm_y+=(ef_yd);
  4430.  
  4431.                 if ((p2->tm_act==RUN_ACT) || (p2->tm_act==JUMP_ACT))
  4432.                 {
  4433.                     p2->tm_x-=(p2->go_txdis);
  4434.                     p2->tm_y-=(p2->go_tydis);
  4435.                 }
  4436.             }
  4437.         }
  4438.     }
  4439. }
  4440.  
  4441. /******************************************************************************
  4442. *****************************************************************************/
  4443.  
  4444. void player_tussles()
  4445. {
  4446.     int p=0;
  4447.     int p1,p2,op;
  4448.     char same_team=FALSE;
  4449.     while ((tussle_ptr!=&tussle_tab[p]) && (!same_team))
  4450.     {
  4451.         p1=tussle_tab[p++];
  4452.         op=p;
  4453.         same_team=TRUE;
  4454.         while (tussle_ptr!=&tussle_tab[op])
  4455.         {
  4456.             p2=tussle_tab[op++];
  4457.             if (((p1<12) && (p2>11)) || ((p1>11) && (p2<12)))
  4458.             {
  4459.                 same_team=FALSE;
  4460.                 tussle_collision(&teams[p1-1],&teams[p2-1]);
  4461.             }
  4462.         }
  4463.     }
  4464. }
  4465.  
  4466. /******************************************************************************
  4467. *****************************************************************************/
  4468.  
  4469. void inline add_to_tussle_list(int pnum)
  4470. {
  4471.     *tussle_ptr++=pnum;
  4472. }
  4473.  
  4474. /******************************************************************************
  4475. *****************************************************************************/
  4476.  
  4477. void do_action()
  4478. {
  4479.     switch(teams[player_num-1].tm_act)
  4480.     {
  4481.         case STAND_ACT:
  4482.             stand_action(&teams[player_num-1]);
  4483.             break;
  4484.  
  4485.         case RUN_ACT:
  4486.             run_action(&teams[player_num-1]);
  4487.             break;
  4488. /*
  4489.         case TURN_ACT:
  4490.             turn_action(&teams[player_num-1]);
  4491.             break;
  4492. */
  4493.         case TACKLE_ACT:
  4494.             tackle_action(&teams[player_num-1]);
  4495.             break;
  4496.  
  4497.         case FALL_ACT:
  4498.             fall_action(&teams[player_num-1]);
  4499.             break;
  4500.  
  4501.         case JUMP_ACT:
  4502.             jump_action(&teams[player_num-1]);
  4503.             break;
  4504.  
  4505.         case SAVE_ACT:
  4506.             save_action(&teams[player_num-1]);
  4507.             break;
  4508.  
  4509.         case THROW_ACT:
  4510.             throw_action(&teams[player_num-1]);
  4511.             break;
  4512.  
  4513.         case KPHOLD_ACT:
  4514.             kphold_action(&teams[player_num-1]);
  4515.             break;
  4516.  
  4517.         case STEAL_ACT:
  4518.             steal_action(&teams[player_num-1]);
  4519.             break;
  4520.  
  4521.         case KICK_ACT:
  4522.             kick_action(&teams[player_num-1]);
  4523.             break;
  4524.  
  4525.         case CELEB_ACT:
  4526.             celeb_action(&teams[player_num-1]);
  4527.             break;
  4528.  
  4529.         case CONTROL_ACT:
  4530.             control_action(&teams[player_num-1]);
  4531.             break;
  4532.  
  4533.         case STRIKE_ACT:
  4534.             strike_action(&teams[player_num-1]);
  4535.             break;
  4536.  
  4537.         case WAIT_ACT:
  4538.             wait_action(&teams[player_num-1]);
  4539.             break;
  4540.  
  4541.         case PICKUP_ACT:
  4542.             pickup_action(&teams[player_num-1]);
  4543.             break;
  4544.  
  4545.         case STOP_ACT:
  4546.             stop_action(&teams[player_num-1]);
  4547.             break;
  4548.     }
  4549. }
  4550.  
  4551. /******************************************************************************
  4552. *****************************************************************************/
  4553.  
  4554. void new_dir(match_player *player,float x,float y)
  4555. {
  4556.     float d=calc_dist(x,y);
  4557.     float max;
  4558.  
  4559. // get maximum turn.
  4560.     max=MAX_TURN;
  4561.  
  4562. // get new normalised vector.
  4563.     float nx=x/d;
  4564.     float ny=y/d;
  4565.  
  4566.     float ox=player->tm_xdis;
  4567.     float oy=player->tm_ydis;
  4568.         
  4569. // get difference (cos a).
  4570.     float dif=((nx*ox)+(ny*oy));
  4571.  
  4572.     if (dif<cos(max))
  4573.     {
  4574.             
  4575. // Which way to turn?
  4576.         if ((nx*oy)>(ny*ox))
  4577.             max=-max;
  4578.         
  4579.         nx=(ox*cos(max))-(oy*sin(max));
  4580.         ny=(oy*cos(max))+(ox*sin(max));
  4581.  
  4582. // Error Correction...
  4583.         d=calc_dist(nx,ny);
  4584.         nx=nx/d;
  4585.         ny=ny/d;
  4586.  
  4587.         if (ny>1)
  4588.         {
  4589.             ny=1;
  4590.             nx=0;
  4591.         }
  4592.  
  4593.         if (ny<-1)
  4594.         {
  4595.             ny=-1;
  4596.             nx=0;
  4597.         }
  4598.  
  4599.         if (nx>1)
  4600.         {
  4601.             nx=1;
  4602.             ny=0;
  4603.         }
  4604.  
  4605.         if (nx<-1)
  4606.         {
  4607.             nx=-1;
  4608.             ny=0;
  4609.         }
  4610.     }
  4611.  
  4612.     player->tm_xdis=nx;
  4613.     player->tm_ydis=ny;
  4614.     player->face_dir=get_dir(player->tm_xdis,player->tm_ydis);
  4615. }
  4616.  
  4617. /******************************************************************************
  4618. *****************************************************************************/
  4619.  
  4620. void dir_movement(match_player *player)
  4621. {
  4622.     float x,y;
  4623.  
  4624.     if (user_controlled && !player->tm_act && player->tm_player==ball_poss)
  4625.     {
  4626.         x=player->tm_xdis*10;
  4627.         y=player->tm_ydis*10;
  4628.     }
  4629.     else
  4630.     {
  4631.         x=player->go_tx-player->tm_x;
  4632.         y=player->go_ty-player->tm_y;
  4633.     }
  4634.  
  4635.     if ((x!=0) || (y!=0))
  4636.         new_dir(player,x,y);
  4637. }
  4638.  
  4639. /******************************************************************************
  4640. *****************************************************************************/
  4641.  
  4642. void dir_ball(match_player *player)
  4643. {
  4644.     float x=ballx-player->tm_x;
  4645.     float y=bally-player->tm_y;
  4646.     if ((x!=0) || (y!=0))
  4647.         new_dir(player,x,y);
  4648. }
  4649.  
  4650. /******************************************************************************
  4651. *****************************************************************************/
  4652.  
  4653. void dir_new_d(match_player *player)
  4654. {
  4655.     new_dir(player,newdx,newdy);
  4656. }
  4657.  
  4658. /******************************************************************************
  4659. *****************************************************************************/
  4660.  
  4661. void dir_must_face(match_player *player)
  4662. {
  4663.     new_dir(player,player->mface_x,player->mface_y);
  4664. }
  4665.  
  4666. /******************************************************************************
  4667. *****************************************************************************/
  4668.  
  4669. void dir_away(match_player *player)
  4670. {
  4671.     float x;
  4672.     float y=0;
  4673.  
  4674.     if (player->tm_player<12)
  4675.         x=1;
  4676.     else
  4677.         x=-1;
  4678.  
  4679.     new_dir(player,x,y);
  4680. }
  4681.  
  4682. /******************************************************************************
  4683. *****************************************************************************/
  4684.  
  4685. void select_hlite(match_player *player,short u)
  4686. {
  4687.     player->tm_hcol=u-1;                // Highlight colour.
  4688.     if (ball_poss==player->tm_player)
  4689.     {
  4690.         if (in_cross_area)
  4691.             player->tm_htype=HLITE_CROSS;
  4692.         else
  4693.             if (player->tm_srng)
  4694.                 player->tm_htype=HLITE_SHOOT;
  4695.             else
  4696.                 player->tm_htype=HLITE_BALL;
  4697.     }
  4698.     else
  4699.     {
  4700.         if (player->special>0 && player->int_move==I_INTERCEPT)
  4701.             player->tm_htype=HLITE_SPECIAL;
  4702.         else
  4703.             if (player->special<0 && player->int_move==I_INTERCEPT)
  4704.                 player->tm_htype=HLITE_STAR;
  4705.             else
  4706.                 player->tm_htype=HLITE_NORM;
  4707.     }
  4708. }
  4709.  
  4710. /******************************************************************************
  4711. *****************************************************************************/
  4712.  
  4713. void user_conts(match_player *player)
  4714. {
  4715.     short u=player->control;
  4716.     if (u)
  4717.     {
  4718.         ux=users_dir[u-1].x;
  4719.         uy=users_dir[u-1].y;
  4720.         um=users_dir[u-1].m;
  4721.  
  4722.         if (users_dir[u-1].f&1)
  4723.         {
  4724.             uf1=TRUE;
  4725.             if (player->tm_player==KP_B)
  4726.                 uf1++;
  4727.         }
  4728.         else
  4729.             uf1=FALSE;
  4730.  
  4731.         if (users_dir[u-1].f&2)
  4732.         {
  4733.             uf2=TRUE;
  4734.         }
  4735.         else
  4736.         {
  4737.             uf2=FALSE;
  4738.         }
  4739.  
  4740.         if (uf1 || uf2)
  4741.         {
  4742.     // Any fire buttons pressed?
  4743.             if (users[u-1].chng)
  4744.     // Just been selected... wait for release of buttons...
  4745.             {
  4746.                 uf1=FALSE;
  4747.                 uf2=FALSE;
  4748.             }
  4749.         }
  4750.         else
  4751.         {
  4752.             if (users[u-1].chng)
  4753.     // Buttons released...
  4754.                 users[u-1].chng=FALSE;
  4755.         }
  4756.  
  4757. #ifdef FORCE_SELECT
  4758.  
  4759. #ifdef EURO96
  4760.         if (uf2 && uf1 && player->tm_dist>FSELECT_DIST && users[u-1].type<0)
  4761. #endif
  4762.  
  4763. #ifndef EURO96
  4764.         if (uf2 && player->tm_dist>FSELECT_DIST && users[u-1].type<0)
  4765. #endif
  4766.         {
  4767.             uf1=FALSE;
  4768.             uf2=FALSE;
  4769.  
  4770.             if ((forced>>(u-1))&1)
  4771.                  forced-=1<<(u-1);
  4772.             else
  4773.                  forced+=1<<(u-1);
  4774.         }
  4775.         else
  4776.             if ((forced>>(u-1))&1)
  4777.                  forced-=1<<(u-1);
  4778. #endif
  4779.     }
  4780. }
  4781. /******************************************************************************
  4782. *****************************************************************************/
  4783.  
  4784. void process_dir(match_player *player)
  4785. {
  4786.     switch(player->dir_mode)
  4787.     {
  4788.         case(0):
  4789.             dir_movement(player);
  4790.             break;
  4791.  
  4792.         case(-1):
  4793.             dir_movement(player);
  4794.             player->dir_mode=1;
  4795.             break;
  4796.  
  4797.         case(1):
  4798.             dir_ball(player);
  4799.             break;
  4800.  
  4801.         case(2):
  4802.             player->face_dir=get_dir(player->tm_xdis,player->tm_ydis);
  4803.             break;
  4804.  
  4805.         case(3):
  4806.             dir_away(player);
  4807.             break;
  4808.  
  4809.         case(4):
  4810.             player->face_dir=get_dir(player->tm_xdis,player->tm_ydis);
  4811.             player->dir_mode=0;
  4812.             break;
  4813.  
  4814.         case(5):
  4815.             dir_new_d(player);
  4816.             break;
  4817.  
  4818.         case(6):
  4819.             dir_must_face(player);
  4820.             break;
  4821.  
  4822.     };
  4823. }
  4824.  
  4825. /******************************************************************************
  4826. *****************************************************************************/
  4827.  
  4828. void init_stand_anim(match_player *player)
  4829. {
  4830.     player->tm_anim=MC_STAND;
  4831.     player->tm_newanim=TRUE;
  4832.     player->tm_frm=0;
  4833.     player->tm_fstep=MC_STAND_FS;
  4834. }
  4835.  
  4836. /******************************************************************************
  4837. *****************************************************************************/
  4838.  
  4839. void init_penalty_anim(match_player *player)
  4840. {
  4841.     if (player->tm_anim!=MC_PENALTY)
  4842.     {
  4843.         player->tm_anim=MC_PENALTY;
  4844.         player->tm_newanim=TRUE;
  4845.         player->tm_frm=0;
  4846.         player->tm_fstep=MC_PENALTY_FS;
  4847.     }
  4848. }
  4849.  
  4850. /******************************************************************************
  4851. *****************************************************************************/
  4852.  
  4853. void init_shame_anim(match_player *player)
  4854. {
  4855.     player->tm_anim=MC_SHAMEW;
  4856.     player->tm_newanim=TRUE;
  4857.     player->tm_frm=0;
  4858.     player->tm_fstep=MC_SHAMEW_FS;
  4859. }
  4860.  
  4861. /******************************************************************************
  4862. *****************************************************************************/
  4863.  
  4864. void init_standb_anim(match_player *player)
  4865. {
  4866.     player->tm_anim=MC_STANDB;
  4867.     player->tm_newanim=TRUE;
  4868.     player->tm_frm=0;
  4869.     player->tm_fstep=MC_STANDB_FS;
  4870. }
  4871.  
  4872. /******************************************************************************
  4873. *****************************************************************************/
  4874.  
  4875. void init_barge_anim(match_player *player)
  4876. {
  4877. // Always go from run animation to barge!
  4878.  
  4879.     player->tm_anim=MC_BARGE;
  4880.     player->tm_fstep=MC_BARGE_FS*(actual_spd(player)/MC_RUN_SPD);
  4881.     player->tm_frm+=0.5;
  4882. }
  4883.  
  4884. /******************************************************************************
  4885. *****************************************************************************/
  4886.  
  4887. void init_run_anim(match_player *player)
  4888. {
  4889.     if (!player->tm_barge || player->tm_anim!=MC_BARGE)
  4890.     {
  4891. // Not barging!!!
  4892.         if (user_controlled && uf2)
  4893.             player->tm_fstep=(MC_RUN_FS*(actual_spd(player)/MC_RUN_SPD))*1.2;
  4894.         else
  4895.             player->tm_fstep=MC_RUN_FS*(actual_spd(player)/MC_RUN_SPD);
  4896.     
  4897.         if (ABS((int)player->tm_anim)==MC_JOG)
  4898.         {
  4899. // Tween to run from jog....
  4900.             player->tm_anim=MC_RUN;
  4901.             player->tm_frm+=0.4;
  4902.         }
  4903.         else
  4904.         {
  4905.             if (ABS((int)player->tm_anim)!=MC_RUN)
  4906.             {
  4907.                 player->tm_anim=MC_RUN;
  4908.                 player->tm_newanim=TRUE;
  4909.                 player->tm_frm=0;
  4910.             }
  4911.         }    
  4912.     }
  4913. }
  4914.  
  4915. /******************************************************************************
  4916. *****************************************************************************/
  4917.  
  4918. void init_jog_anim(match_player *player)
  4919. {
  4920.     player->tm_fstep=MC_JOG_FS*((actual_spd(player)/2)/MC_JOG_SPD);
  4921.  
  4922.     if (ABS((int)player->tm_anim)==MC_RUN)
  4923.     {
  4924. // Tween to jog from run....
  4925.         player->tm_anim=MC_JOG;
  4926.         player->tm_frm+=0.7;
  4927.     }
  4928.     else
  4929.     {
  4930.         if (ABS((int)player->tm_anim)==MC_BARGE)
  4931.         {
  4932.             player->tm_anim=MC_JOG;
  4933.         }
  4934.         else
  4935.         {
  4936.             if (ABS((int)player->tm_anim)!=MC_JOG)
  4937.             {
  4938.                 player->tm_anim=MC_JOG;
  4939.                 player->tm_newanim=TRUE;
  4940.                 player->tm_frm=0;
  4941.             }
  4942.         }
  4943.     }
  4944. }
  4945.  
  4946. /******************************************************************************
  4947. *****************************************************************************/
  4948.  
  4949. void init_shoot_anim(match_player *player)
  4950. {
  4951.     player->tm_fstep=MC_SHOOT_FS;
  4952.     double n;
  4953.  
  4954.     if ((AFEQS(player->tm_anim,MC_RUN)) ||
  4955.         (AFEQS(player->tm_anim,MC_JOG)))
  4956.     {
  4957.         if (modf(player->tm_frm,&n)>0.5)
  4958.         {
  4959. // Left Footed Shot...
  4960.             player->tm_anim=MC_SHOOTL;
  4961.             player->tm_newanim=TRUE;
  4962.             player->tm_frm-=0.5;
  4963.         }
  4964.         else
  4965.         {
  4966. // Right Footed Shot...
  4967.             player->tm_anim=MC_SHOOTR;
  4968.             player->tm_newanim=TRUE;
  4969.         }
  4970.     }
  4971.     else
  4972.     {
  4973. // Right Footed Shot...
  4974.             player->tm_anim=MC_SHOOTR;
  4975.             player->tm_newanim=TRUE;
  4976.             player->tm_frm=0;
  4977.     }
  4978. }
  4979.  
  4980. /******************************************************************************
  4981. *****************************************************************************/
  4982.  
  4983. void init_kick_anim(match_player *player,int a)
  4984. {
  4985.     int an=a;
  4986.     double n;
  4987.     float t;
  4988.     float f;
  4989.  
  4990.     if (AFEQS(player->tm_anim,MC_RUN))
  4991.         t=modf(player->tm_frm,&n);
  4992.     else    
  4993.         if (AFEQS(player->tm_anim,MC_JOG) || AFEQS(player->tm_anim,MC_BARGE))
  4994.             t=modf((player->tm_frm+0.5),&n);
  4995.  
  4996.     if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)) || (AFEQS(player->tm_anim,MC_BARGE)))
  4997.     {
  4998.         switch(a)
  4999.         {
  5000.             case(MC_PASSL):
  5001.             case(MC_CHIPL):
  5002.             case(MC_BACKHEELL):
  5003.                 if (t>=0.3 && t<0.8)
  5004.                 {
  5005. // Right Footed...
  5006.                     t=(t-0.3);
  5007.                     an-=1;
  5008.                 }
  5009.                 else
  5010.                 {
  5011. // Left Footed...
  5012.                     if (t<0.3)
  5013.                         t=(t+0.2);
  5014.                     else
  5015.                         t=(t-0.8);
  5016.                 }
  5017.  
  5018.                 switch(a)
  5019.                 {
  5020.                     case(MC_TOEL):
  5021.                         f=0.7;
  5022.                         break;
  5023.  
  5024.                     default:
  5025.                         f=0.8;
  5026.                         break;
  5027.                 }
  5028.  
  5029.                 player->tm_anim=ABS(an);
  5030.                 player->tm_newanim=TRUE;
  5031.                 player->tm_frm=(t*f);
  5032.                 break;
  5033.  
  5034.             case(MC_SHOOTL):
  5035.             case(MC_CROSSL):
  5036.                 if (t>=0.25 && t<0.75)
  5037.                 {
  5038. // Right Footed...
  5039.                     t=(t-0.25);
  5040.                     an-=1;
  5041.                 }
  5042.                 else
  5043.                 {
  5044. // Left Footed...
  5045.                     if (t<0.25)
  5046.                         t=(t+0.25);
  5047.                     else
  5048.                         t=(t-0.75);
  5049.                 }
  5050.  
  5051.                 switch(a)
  5052.                 {
  5053.                     case(MC_SHOOTL):
  5054.                         f=0.6;
  5055.                         break;
  5056.  
  5057.                     case(MC_CROSSL):
  5058.                         f=0.5;
  5059.                         break;
  5060.                 }
  5061.  
  5062.                 player->tm_anim=ABS(an);
  5063.                 player->tm_newanim=TRUE;
  5064.                 player->tm_frm=(t*f);
  5065.                 break;
  5066.  
  5067.         }
  5068.     }
  5069.     else
  5070.     {
  5071. // Right Footed...
  5072.         player->tm_anim=ABS(an);
  5073.         player->tm_newanim=TRUE;
  5074.         player->tm_frm=0;
  5075.     }
  5076.  
  5077.     switch(a)
  5078.     {
  5079.         case(MC_PASSL):
  5080.             player->tm_fstep=MC_PASS_FS;
  5081.             break;
  5082.         case(MC_CHIPL):
  5083.             player->tm_fstep=MC_CHIP_FS;
  5084.             break;
  5085.         case(MC_BACKHEELL):
  5086.             player->tm_fstep=MC_BACKHEEL_FS;
  5087.             break;
  5088.         case(MC_SHOOTL):
  5089.             player->tm_fstep=MC_SHOOT_FS;
  5090.             break;
  5091.         case(MC_CROSSL):
  5092.             player->tm_fstep=MC_CROSS_FS;
  5093.             break;
  5094.     }        
  5095. }
  5096.  
  5097. /******************************************************************************
  5098. *****************************************************************************/
  5099.  
  5100. void init_kick_l_anim(match_player *player,int a)
  5101. {
  5102.     int an=a;
  5103.     double n;
  5104.     float t;
  5105.  
  5106.     if (AFEQS(player->tm_anim,MC_RUN))
  5107.         t=modf(player->tm_frm,&n);
  5108.     else    
  5109.         if (AFEQS(player->tm_anim,MC_JOG))
  5110.             t=modf((player->tm_frm+0.5),&n);
  5111.  
  5112.     if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)))
  5113.     {
  5114. // Left Footed...
  5115.         if (t<0.3)
  5116.             t=(t+0.2);
  5117.         else
  5118.             if (t>0.8)
  5119.                 t=(t-0.8);
  5120.             else
  5121.                 t=0;
  5122.  
  5123.         player->tm_frm=(t*0.8);
  5124.     }
  5125.     else
  5126.         player->tm_frm=0;
  5127.  
  5128.     player->tm_anim=ABS(an);
  5129.     player->tm_newanim=TRUE;
  5130.  
  5131.     switch(an)
  5132.     {
  5133.         case(MC_DIAGPASSL):
  5134.             player->tm_fstep=MC_DIAGPASS_FS;
  5135.             break;
  5136.         case(MC_DIAGBACKL):
  5137.             player->tm_fstep=MC_DIAGBACK_FS;
  5138.             break;
  5139.         case(MC_SIDEPASSL):
  5140.             player->tm_fstep=MC_SIDEPASS_FS;
  5141.             break;
  5142.     }
  5143. }
  5144.  
  5145. /******************************************************************************
  5146. *****************************************************************************/
  5147.  
  5148. void init_kick_r_anim(match_player *player,int a)
  5149. {
  5150.     int an=a;
  5151.     double n;
  5152.     float t;
  5153.  
  5154.     if (AFEQS(player->tm_anim,MC_RUN))
  5155.         t=modf(player->tm_frm,&n);
  5156.     else    
  5157.         if (AFEQS(player->tm_anim,MC_JOG))
  5158.             t=modf((player->tm_frm+0.5),&n);
  5159.  
  5160.     if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)))
  5161.     {
  5162.         if (t>=0.3 && t<0.8)
  5163.         {
  5164. // Right Footed...
  5165.             t=(t-0.3);
  5166.         }
  5167.         else
  5168.             t=0;
  5169.  
  5170.         player->tm_frm=(t*0.8);
  5171.     }
  5172.     else
  5173.         player->tm_frm=0;
  5174.  
  5175.     player->tm_anim=ABS(an);
  5176.     player->tm_newanim=TRUE;
  5177.  
  5178.     switch(an)
  5179.     {
  5180.         case(MC_DIAGPASSR):
  5181.             player->tm_fstep=MC_DIAGPASS_FS;
  5182.             break;
  5183.         case(MC_DIAGBACKR):
  5184.             player->tm_fstep=MC_DIAGBACK_FS;
  5185.             break;
  5186.         case(MC_SIDEPASSR):
  5187.             player->tm_fstep=MC_SIDEPASS_FS;
  5188.             break;
  5189.     }
  5190. }
  5191.  
  5192. /******************************************************************************
  5193. *****************************************************************************/
  5194.  
  5195. void init_trap_anim(match_player *player)
  5196. {
  5197.     player->tm_fstep=MC_TRAP_FS*fstep_factor(player->tm_cont);
  5198.     player->tm_frm=0;
  5199.     player->tm_newanim=TRUE;
  5200.     double n;
  5201.  
  5202.     if (AFEQS(player->tm_anim,MC_RUN))
  5203.     {
  5204.         if (modf(player->tm_frm,&n)>=0.4 && modf(player->tm_frm,&n)<0.9)
  5205.         {
  5206. // Left Footed Trap...
  5207.             player->tm_anim=MC_TRAPL;
  5208.         }
  5209.         else
  5210.         {
  5211. // Right Footed Trap...
  5212.             player->tm_anim=MC_TRAPR;
  5213.         }
  5214.     }
  5215.     else
  5216.     {
  5217. // Right Footed Trap...
  5218.             player->tm_anim=MC_TRAPR;
  5219.     }
  5220. }
  5221.  
  5222. /******************************************************************************
  5223. *****************************************************************************/
  5224.  
  5225. void init_ride_anim(match_player *player)
  5226. {
  5227.     double n;
  5228.     float t;
  5229.  
  5230.     if (AFEQS(player->tm_anim,MC_RUN))
  5231.         t=modf(player->tm_frm,&n);
  5232.     else    
  5233.         if (AFEQS(player->tm_anim,MC_JOG))
  5234.             t=modf((player->tm_frm+0.5),&n);
  5235.  
  5236.     if ((AFEQS(player->tm_anim,MC_JOG)) || (AFEQS(player->tm_anim,MC_RUN)))
  5237.     {
  5238.         if (t>=0.35 && t<0.85)
  5239.         {
  5240. // Left Footed...
  5241.             player->tm_anim=MC_RIDEL;
  5242.             player->tm_newanim=TRUE;
  5243.             t=(t-0.35);
  5244.         }
  5245.         else
  5246.         {
  5247. // Right Footed...
  5248.             player->tm_anim=MC_RIDER;
  5249.             player->tm_newanim=TRUE;
  5250.             if (t>=0.85)
  5251.                 t=t-0.85;
  5252.             else
  5253.                 t=t+0.15;
  5254.         }
  5255.         player->tm_frm=(t*2/5);
  5256.     }
  5257.     else
  5258.     {
  5259.         player->tm_frm=0;
  5260.         player->tm_anim=MC_RIDEL;
  5261.         player->tm_newanim=TRUE;
  5262.     }
  5263.  
  5264. // Player's speed and flair determine how fast he rides tackle...
  5265.     float f=(player->tm_flair+player->tm_rate)/2;
  5266.     f=MC_RIDE_FS+(0.000536*f);
  5267.     player->tm_fstep=f;
  5268. }
  5269.  
  5270. /******************************************************************************
  5271. *****************************************************************************/
  5272.  
  5273. void init_tack_anim(match_player *player)
  5274. {
  5275.     player->tm_fstep=MC_S_TACKLE_FS;
  5276.     player->tm_anim=MC_S_TACKLE;
  5277.     player->tm_newanim=TRUE;
  5278.     player->tm_frm=0;
  5279. }
  5280.  
  5281. /******************************************************************************
  5282. *****************************************************************************/
  5283.  
  5284. void init_shdr_anim(match_player *player)
  5285. {
  5286.     if ((ABS((int)player->tm_anim)!=MC_S_HEAD) && (ABS((int)player->tm_anim)!=MC_J_HEAD))
  5287.     {
  5288.         player->tm_fstep=MC_S_HEAD_FS*fstep_factor(player->tm_flair);
  5289.         player->tm_anim=MC_S_HEAD;
  5290.         player->tm_newanim=TRUE;
  5291.         player->tm_frm=0;
  5292.     }
  5293. }
  5294.  
  5295. /******************************************************************************
  5296. *****************************************************************************/
  5297.  
  5298. void init_jhdr_anim(match_player *player)
  5299. {
  5300.     player->tm_fstep=MC_J_HEAD_FS*fstep_factor(player->tm_flair);
  5301.     player->tm_anim=MC_J_HEAD;
  5302.     player->tm_newanim=TRUE;
  5303.     player->tm_frm=0;
  5304. }
  5305.  
  5306. /******************************************************************************
  5307. *****************************************************************************/
  5308.  
  5309. void init_dhdr_anim(match_player *player)
  5310. {
  5311.     player->tm_fstep=MC_DV_HEAD_FS*fstep_factor(player->tm_flair);
  5312.     player->tm_anim=MC_DV_HEAD;
  5313.     player->tm_newanim=TRUE;
  5314.     player->tm_frm=0;
  5315. }
  5316.  
  5317. /******************************************************************************
  5318. *****************************************************************************/
  5319.  
  5320. void init_ohd_anim(match_player *player)
  5321. {
  5322.     player->tm_fstep=MC_OVERHEAD_FS*fstep_factor(player->tm_flair);
  5323.     player->tm_anim=MC_OVERHEAD;
  5324.     player->tm_newanim=TRUE;
  5325.     player->tm_frm=0;
  5326. }
  5327.  
  5328. /******************************************************************************
  5329. *****************************************************************************/
  5330.  
  5331. void init_voll_anim(match_player *player)
  5332. {
  5333.     player->tm_fstep=MC_VOLLEY_FS*fstep_factor(player->tm_flair);
  5334.     player->tm_anim=MC_VOLLEYL;
  5335.     player->tm_newanim=TRUE;
  5336.     player->tm_frm=0;
  5337. }
  5338.  
  5339. /******************************************************************************
  5340. *****************************************************************************/
  5341.  
  5342. void init_fallr_anim(match_player *player)
  5343. {
  5344.     player->tm_fstep=MC_FALLR_FS;
  5345.     player->tm_anim=MC_FALLR;
  5346.     player->tm_newanim=TRUE;
  5347.     player->tm_frm=0;
  5348. }
  5349.  
  5350. /******************************************************************************
  5351. *****************************************************************************/
  5352.  
  5353. void init_chest_anim(match_player *player)
  5354. {
  5355.     player->tm_fstep=MC_CHEST_FS*fstep_factor(player->tm_cont);
  5356.     player->tm_anim=MC_CHEST;
  5357.     player->tm_newanim=TRUE;
  5358.     player->tm_frm=0;
  5359. }
  5360.  
  5361. /******************************************************************************
  5362. *****************************************************************************/
  5363.  
  5364. void init_dnhead_anim(match_player *player)
  5365. {
  5366.     player->tm_fstep=MC_D_HEAD_FS*fstep_factor(player->tm_cont);
  5367.     player->tm_anim=MC_D_HEAD;
  5368.     player->tm_newanim=TRUE;
  5369.     player->tm_frm=0;
  5370. }
  5371.  
  5372. /******************************************************************************
  5373. *****************************************************************************/
  5374.  
  5375. void init_getupf_anim(match_player *player)
  5376. {
  5377.     player->tm_fstep=MC_GETUPF_FS;
  5378.     player->tm_anim=MC_GETUPF;
  5379.     player->tm_newanim=TRUE;
  5380.     player->tm_frm=0;
  5381. }
  5382.  
  5383. /******************************************************************************
  5384. *****************************************************************************/
  5385.  
  5386. void init_getup_anim(match_player *player)
  5387. {
  5388.     player->tm_fstep=MC_GETUP_FS;
  5389.     player->tm_anim=MC_GETUP;
  5390.     player->tm_newanim=TRUE;
  5391.     player->tm_frm=0;
  5392. }
  5393.  
  5394. /******************************************************************************
  5395. *****************************************************************************/
  5396.  
  5397. void init_save_anim(match_player *player,int an)
  5398. {
  5399.     player->tm_anim=ABS(an);
  5400.     player->tm_newanim=TRUE;
  5401.     player->tm_frm=0;
  5402. }
  5403.  
  5404. /******************************************************************************
  5405. *****************************************************************************/
  5406.  
  5407. void init_bounce_anim(match_player *player)
  5408. {
  5409.     player->tm_anim=MC_BOUNCE;
  5410.     player->tm_newanim=TRUE;
  5411.     player->tm_frm=0;
  5412.     player->tm_fstep=MC_BOUNCE_FS;
  5413. }
  5414.  
  5415. /******************************************************************************
  5416. *****************************************************************************/
  5417.  
  5418. void init_kout_anim(match_player *player)
  5419. {
  5420.     player->tm_anim=MC_KICKOUT;
  5421.     player->tm_newanim=TRUE;
  5422.     player->tm_frm=0;
  5423.     player->tm_fstep=MC_KICKOUT_FS;
  5424. }
  5425.  
  5426. /******************************************************************************
  5427. *****************************************************************************/
  5428.  
  5429. void init_hvoll_anim(match_player *player)
  5430. {
  5431.     player->tm_anim=MC_HALFVOLL;
  5432.     player->tm_newanim=TRUE;
  5433.     player->tm_frm=0;
  5434.     player->tm_fstep=MC_HALFVOLL_FS;
  5435. }
  5436.  
  5437. /******************************************************************************
  5438. *****************************************************************************/
  5439.  
  5440. void init_throw_anim(match_player *player)
  5441. {
  5442.     player->tm_anim=MC_THROW;
  5443.     player->tm_newanim=TRUE;
  5444.     player->tm_frm=0;
  5445.     player->tm_fstep=MC_THROW_FS;
  5446. }
  5447.  
  5448. /******************************************************************************
  5449. *****************************************************************************/
  5450.  
  5451. void init_roll_anim(match_player *player)
  5452. {
  5453.     player->tm_anim=MC_ROLL;
  5454.     player->tm_newanim=TRUE;
  5455.     player->tm_frm=0;
  5456.     player->tm_fstep=MC_ROLL_FS;
  5457. }
  5458.  
  5459. /******************************************************************************
  5460. *****************************************************************************/
  5461.  
  5462. void init_runb_anim(match_player *player)
  5463. {
  5464.     player->tm_anim=MC_RUNWITHB;
  5465.     player->tm_newanim=TRUE;
  5466.     player->tm_frm=0;
  5467.     player->tm_fstep=MC_RUNWITHB_FS;
  5468. }
  5469.  
  5470. /******************************************************************************
  5471. *****************************************************************************/
  5472.  
  5473. void init_waveup_anim(match_player *player)
  5474. {
  5475.     player->tm_anim=MC_WAVEUP;
  5476.     player->tm_newanim=TRUE;
  5477.     player->tm_frm=0;
  5478.     player->tm_fstep=MC_WAVEUP_FS;
  5479. }
  5480.  
  5481. /******************************************************************************
  5482. *****************************************************************************/
  5483.  
  5484. void init_throwl_anim(match_player *player)
  5485. {
  5486.     player->tm_anim=MC_THROWL;
  5487.     player->tm_newanim=TRUE;
  5488.     player->tm_frm=0.02;
  5489.     player->tm_fstep=MC_THROWL_FS;
  5490. }
  5491.  
  5492. /******************************************************************************
  5493. *****************************************************************************/
  5494.  
  5495. void init_throws_anim(match_player *player)
  5496. {
  5497.     player->tm_anim=MC_THROWS;
  5498.     player->tm_newanim=TRUE;
  5499.     player->tm_frm=0.02;
  5500.     player->tm_fstep=MC_THROWS_FS;
  5501. }
  5502.  
  5503. /******************************************************************************
  5504. *****************************************************************************/
  5505.  
  5506. void init_crtostb_anim(match_player *player)
  5507. {
  5508.     player->tm_anim=MC_CRTOSTB;
  5509.     player->tm_newanim=TRUE;
  5510.     player->tm_frm=0;
  5511.     player->tm_fstep=MC_CRTOSTB_FS;
  5512. }
  5513.  
  5514. /******************************************************************************
  5515. *****************************************************************************/
  5516.  
  5517. void init_crl_anim(match_player *player)
  5518. {
  5519.     player->tm_anim=MC_CROSSL;
  5520.     player->tm_newanim=TRUE;
  5521.     player->tm_frm=0;
  5522.     player->tm_fstep=MC_CROSS_FS;
  5523. }
  5524. /******************************************************************************
  5525. *****************************************************************************/
  5526.  
  5527. void init_crr_anim(match_player *player)
  5528. {
  5529.     player->tm_anim=MC_CROSSR;
  5530.     player->tm_newanim=TRUE;
  5531.     player->tm_frm=0;
  5532.     player->tm_fstep=MC_CROSS_FS;
  5533. }
  5534.  
  5535. /******************************************************************************
  5536. *****************************************************************************/
  5537.  
  5538. void init_tostand_anim(match_player *player,int an)
  5539. {
  5540.     player->tm_anim=ABS(an);
  5541.     player->tm_newanim=TRUE;
  5542.     player->tm_frm=0;
  5543.     player->tm_fstep=MC_STOS_FS;
  5544. }
  5545.  
  5546. /******************************************************************************
  5547. *****************************************************************************/
  5548.  
  5549. void init_tostandb_anim(match_player *player,int an)
  5550. {
  5551.     player->tm_anim=ABS(an);
  5552.     player->tm_newanim=TRUE;
  5553.     player->tm_frm=0;
  5554.     player->tm_fstep=MC_STOSB_FS;
  5555. }
  5556.  
  5557. /******************************************************************************
  5558. *****************************************************************************/
  5559.  
  5560. void init_socks_anim(match_player *player,int an)
  5561. {
  5562.     player->tm_anim=ABS(an);
  5563.     player->tm_newanim=TRUE;
  5564.     player->tm_frm=0;
  5565.     player->tm_fstep=MC_SOCKS_FS;
  5566. }
  5567.  
  5568. /******************************************************************************
  5569. *****************************************************************************/
  5570.  
  5571. void init_celeb_anim(match_player *player,int an)
  5572. {
  5573.     player->tm_anim=ABS(an);
  5574.     player->tm_newanim=TRUE;
  5575.     player->tm_frm=0;
  5576.     switch(an)
  5577.     {
  5578.         case(MC_CELEB):
  5579.             player->tm_fstep=MC_CELEB_FS;
  5580.             break;
  5581.  
  5582.         case(MC_PUMP):
  5583.             player->tm_fstep=MC_PUMP_FS;
  5584.             break;
  5585.  
  5586.         case(MC_BABY):
  5587.             player->tm_fstep=MC_BABY_FS;
  5588.             break;
  5589.  
  5590.         case(MC_REEVES):
  5591.             player->tm_fstep=MC_REEVES_FS;
  5592.             break;
  5593.  
  5594.         case(MC_MILLER):
  5595.             player->tm_fstep=MC_MILLER_FS;
  5596.             break;
  5597.  
  5598.         case(MC_PLANE):
  5599.             player->tm_fstep=MC_PLANE_FS;
  5600.             break;
  5601.  
  5602.         case(MC_FINGER):
  5603.             player->tm_fstep=MC_FINGER_FS;
  5604.             break;
  5605.  
  5606.         case(MC_KNEE):
  5607.             player->tm_fstep=MC_KNEE_FS;
  5608.             break;
  5609.  
  5610.         case(MC_MOON):
  5611.             player->tm_fstep=MC_MOON_FS;
  5612.             break;
  5613.  
  5614.         case(MC_DUCK):
  5615.             player->tm_fstep=MC_DUCK_FS;
  5616.             break;
  5617.     }
  5618. }
  5619.  
  5620. /******************************************************************************
  5621. *****************************************************************************/
  5622.  
  5623. void init_pickup_anim(match_player *player)
  5624. {
  5625.     player->tm_anim=MC_PICKBALL;
  5626.     player->tm_newanim=TRUE;
  5627.     player->tm_frm=0;
  5628.     player->tm_fstep=MC_PICKBALL_FS;
  5629. }
  5630.  
  5631. /******************************************************************************
  5632. *****************************************************************************/
  5633.  
  5634. void init_trot_anim(match_player *player)
  5635. {
  5636.     float x=player->go_tx-player->tm_x;
  5637.     float y=player->go_ty-player->tm_y;
  5638.  
  5639.     float d=calc_dist(x,y);
  5640. // d is effective speed!
  5641.     player->tm_fstep=actual_spd(player)*MC_TROTA_FS/2;
  5642.  
  5643.     x=x/d;
  5644.     y=y/d;
  5645.  
  5646.     float nx=(x*player->tm_xdis)+(y*player->tm_ydis);
  5647.     float ny=(y*player->tm_xdis)-(x*player->tm_ydis);
  5648.  
  5649.     if (player->tm_anim<MC_TROTB || player->tm_anim>MC_TROTE)
  5650. // Not currently in trot animation...
  5651.     {
  5652.         player->tm_frm=0;
  5653.         player->tm_newanim=TRUE;
  5654.     }
  5655.     
  5656.     switch((1+get_dir(nx,ny)))
  5657.     {
  5658.         case(8):
  5659.             player->tm_anim=MC_TROTF;
  5660.             break;
  5661.  
  5662.         case(7):
  5663.             player->tm_anim=MC_TROTG;
  5664.             break;
  5665.  
  5666.         case(6):
  5667.             player->tm_anim=MC_TROTH;
  5668.             break;
  5669.  
  5670.         case(5):
  5671.             player->tm_anim=MC_TROTA;
  5672.             break;
  5673.  
  5674.         case(4):
  5675.             player->tm_anim=MC_TROTB;
  5676.             break;
  5677.  
  5678.         case(3):
  5679.             player->tm_anim=MC_TROTC;
  5680.             break;
  5681.  
  5682.         case(2):
  5683.             player->tm_anim=MC_TROTD;
  5684.             break;
  5685.  
  5686.         case(1):
  5687.             player->tm_anim=MC_TROTE;
  5688.             break;
  5689.     }
  5690. }
  5691.  
  5692. /******************************************************************************
  5693. *****************************************************************************/
  5694.  
  5695. void init_anim(match_player *player,int an)
  5696. {
  5697. /*
  5698.     if (player->tm_act==STAND_ACT)
  5699.     {
  5700. // Prevent temporary jump to stand animation!
  5701.         player->tm_anim=player->ls_anim;
  5702.         player->tm_frm=player->ls_frm;
  5703.     }
  5704. */    
  5705.     if (an>=MC_AFOOTB && an<=MC_CJUMPBR)
  5706.     {
  5707.         init_save_anim(player,an);
  5708.     }
  5709.     else
  5710.     {
  5711.         switch(an)
  5712.         {
  5713.             case(MC_PASSL):
  5714.             case(MC_CHIPL):
  5715.             case(MC_SHOOTL):
  5716.             case(MC_BACKHEELL):
  5717.                 init_kick_anim(player,an);
  5718.                 break;
  5719.  
  5720.             case(MC_DIAGPASSL):
  5721.             case(MC_DIAGBACKL):
  5722.             case(MC_SIDEPASSL):
  5723.                 init_kick_l_anim(player,an);
  5724.                 break;
  5725.  
  5726.             case(MC_CROSSL):
  5727.                 init_crl_anim(player);
  5728.                 break;
  5729.  
  5730.             case(MC_CROSSR):
  5731.                 init_crr_anim(player);
  5732.                 break;
  5733.  
  5734.             case(MC_DIAGPASSR):
  5735.             case(MC_DIAGBACKR):
  5736.             case(MC_SIDEPASSR):
  5737.                 init_kick_r_anim(player,an);
  5738.                 break;
  5739.  
  5740.             case(MC_STOSL):
  5741.             case(MC_STOSR):
  5742.                 init_tostand_anim(player,an);
  5743.                 break;
  5744.  
  5745.             case(MC_STOSBL):
  5746.             case(MC_STOSBR):
  5747.                 init_tostandb_anim(player,an);
  5748.                 break;
  5749.  
  5750.             case(MC_CRTOSTB):
  5751.                 init_crtostb_anim(player);
  5752.                 break;
  5753.  
  5754.             case(MC_STAND):
  5755.                 init_stand_anim(player);
  5756.                 break;
  5757.  
  5758.             case(MC_PENALTY):
  5759. #ifdef EURO96
  5760.                 init_penalty_anim(player);
  5761. #else
  5762.                 init_stand_anim(player);
  5763. #endif
  5764.                 break;
  5765.  
  5766.             case(MC_SHAME):
  5767.                 init_shame_anim(player);
  5768.                 break;
  5769.  
  5770.             case(MC_TRAPL):
  5771.                 init_trap_anim(player);
  5772.                 break;
  5773.  
  5774.             case(MC_CHEST):
  5775.                 init_chest_anim(player);
  5776.                 break;
  5777.  
  5778.             case(MC_D_HEAD):
  5779.                 init_dnhead_anim(player);
  5780.                 break;
  5781.  
  5782.             case(MC_BARGE):
  5783.                 init_barge_anim(player);
  5784.                 break;
  5785.  
  5786.             case(MC_RUN):
  5787.                 init_run_anim(player);
  5788.                 break;
  5789.  
  5790.             case(MC_JOG):
  5791.                 init_jog_anim(player);
  5792.                 break;
  5793.  
  5794.             case(MC_TROTA):
  5795.                 init_trot_anim(player);
  5796.                 break;
  5797.  
  5798.             case(MC_S_TACKLE):
  5799.                 init_tack_anim(player);
  5800.                 break;
  5801.  
  5802.             case(MC_DV_HEAD):
  5803.                 init_dhdr_anim(player);
  5804.                 break;
  5805.  
  5806.             case(MC_S_HEAD):
  5807.                 init_shdr_anim(player);
  5808.                 break;
  5809.  
  5810.             case(MC_J_HEAD):
  5811.                 init_jhdr_anim(player);
  5812.                 break;
  5813.  
  5814.             case(MC_OVERHEAD):
  5815.                 init_ohd_anim(player);
  5816.                 break;
  5817.  
  5818.             case(MC_VOLLEYL):
  5819.                 init_voll_anim(player);
  5820.                 break;
  5821.  
  5822.             case(MC_FALLR):
  5823.                 init_fallr_anim(player);
  5824.                 break;
  5825.  
  5826.             case(MC_GETUPF):
  5827.                 init_getupf_anim(player);
  5828.                 break;
  5829.  
  5830.             case(MC_GETUP):
  5831.                 init_getup_anim(player);
  5832.                 break;
  5833.  
  5834.             case(MC_RIDEL):
  5835.                 init_ride_anim(player);
  5836.                 break;
  5837.  
  5838.             case(MC_SOCKSL):
  5839.             case(MC_SOCKSR):
  5840.                 init_socks_anim(player,an);
  5841.                 break;
  5842.  
  5843.             case(MC_CELEB):
  5844.             case(MC_KNEE):
  5845.             case(MC_DUCK):
  5846.             case(MC_MOON):
  5847.             case(MC_MILLER):
  5848.             case(MC_BABY):
  5849.             case(MC_PUMP):
  5850.             case(MC_REEVES):
  5851.             case(MC_FINGER):
  5852.             case(MC_PLANE):
  5853.                 init_celeb_anim(player,an);
  5854.                 break;
  5855.  
  5856.             case(MC_PICKBALL):
  5857.                 init_pickup_anim(player);
  5858.                 break;
  5859.  
  5860. // Keeper specific anims...
  5861.  
  5862.             case(MC_STANDB):
  5863.                 init_standb_anim(player);
  5864.                 break;
  5865.  
  5866.             case(MC_BOUNCE):
  5867.                 init_bounce_anim(player);
  5868.                 break;
  5869.  
  5870.             case(MC_KICKOUT):
  5871.                 init_kout_anim(player);
  5872.                 break;
  5873.  
  5874.             case(MC_HALFVOLL):
  5875.                 init_hvoll_anim(player);
  5876.                 break;
  5877.  
  5878.             case(MC_THROW):
  5879.                 init_throw_anim(player);
  5880.                 break;
  5881.  
  5882.             case(MC_ROLL):
  5883.                 init_roll_anim(player);
  5884.                 break;
  5885.  
  5886.             case(MC_RUNWITHB):
  5887.                 init_runb_anim(player);
  5888.                 break;
  5889.  
  5890.             case(MC_WAVEUP):
  5891.                 init_waveup_anim(player);
  5892.                 break;
  5893. /*
  5894.             case(MC_PENALTY):
  5895.                 init_penalty_anim(player);
  5896.                 break;
  5897. */
  5898.             case(MC_THROWL):
  5899.                 init_throwl_anim(player);
  5900.                 break;
  5901.  
  5902.             case(MC_THROWS):
  5903.                 init_throws_anim(player);
  5904.                 break;
  5905.         }
  5906.     }
  5907. }
  5908.  
  5909. /******************************************************************************
  5910. *****************************************************************************/
  5911.  
  5912. void process_anims(match_player *player)
  5913. {
  5914.     if (!(ABS(player->tm_anim)==MC_THROWL && player->tm_frm<0.001))
  5915. // Initial throw-in animation is frozen...
  5916.         player->tm_frm+=player->tm_fstep;
  5917.  
  5918.     if (player->tm_anim==MC_BARGE && player->tm_act==RUN_ACT)
  5919.     {
  5920.         if (!(--player->tm_barge))
  5921.             init_anim(player,MC_RUN);
  5922.     }
  5923.     else
  5924.         player->tm_barge=0;
  5925.  
  5926.     if (player->tm_limbo)
  5927.     {
  5928.         if (!--player->tm_limbo)
  5929.         {
  5930. // Finished animation...
  5931.             int a=ABS(player->tm_anim);
  5932.              switch(a)
  5933.             {
  5934.                 case(MC_KICKOUT):
  5935.                 case(MC_HALFVOLL):
  5936.                 case(MC_THROW):
  5937.                 case(MC_THROWL):
  5938.                 case(MC_THROWS):
  5939.                 case(MC_ROLL):
  5940.                 case(MC_GETUPF):
  5941.                 case(MC_GETUP):
  5942.                     init_stand_act(player);
  5943.             }
  5944.         }
  5945.     }
  5946. }
  5947.  
  5948. /******************************************************************************
  5949. ******************************************************************************/
  5950.  
  5951. // User controls player...
  5952.  
  5953. void user_play(int player_num)
  5954. {
  5955.     user_conts(&teams[player_num-1]);
  5956.  
  5957.     override(&teams[player_num-1]);
  5958.  
  5959.      player_ints(&teams[player_num-1]);
  5960.  
  5961.      user_intelligence(&teams[player_num-1]);
  5962.  
  5963.     if (!teams[player_num-1].tm_limbo && (ball_limbo_on<=0 || (ball_limbo_on>0 && ball_limbo_p!=player_num)))
  5964.     {
  5965.          player_comment(&teams[player_num-1]);
  5966.  
  5967.          do_action();
  5968.     }
  5969. }
  5970.     
  5971. /******************************************************************************
  5972. *****************************************************************************/
  5973.  
  5974. // Computer controls player...
  5975.  
  5976. void computer_play(int player_num)
  5977. {
  5978. #ifdef EURO96
  5979.     if (setp_taker==player_num && ((player_num<12 && !auto_users_a)
  5980.          || (player_num>11 && !auto_users_b)) && already_there
  5981.          && (match_mode==PEN_KICK_A || match_mode==PEN_KICK_B))
  5982.     {
  5983.         if (!allow_replay)
  5984.             init_replay();
  5985.  
  5986.         if (ball_poss!=setp_taker)
  5987.             collect_ball(&teams[setp_taker-1]);
  5988.  
  5989. // Must be a computer penalty kick...
  5990.         if (reselection)
  5991.         {
  5992.             setp_kick_x=teams[setp_taker-1].tm_xdis;
  5993.             setp_kick_y=teams[setp_taker-1].tm_ydis;
  5994.             setp_power=0;
  5995.             setp_hgt=0;
  5996.             setp_byd=cntspot_y;
  5997.             setp_bzd=0;
  5998.             reselection=FALSE;
  5999.         }
  6000.         comp_set_piece(&teams[player_num-1]);
  6001.     }
  6002.     else
  6003. #endif
  6004.     {
  6005.         teams[player_num-1].tm_htype=HLITE_OFF;            // Turn highlight off!
  6006.  
  6007.         override(&teams[player_num-1]);
  6008.  
  6009.         player_ints(&teams[player_num-1]);
  6010.  
  6011.         intelligence(&teams[player_num-1]);
  6012.  
  6013.         if (!teams[player_num-1].tm_limbo && (ball_limbo_on<=0 || (ball_limbo_on>0 && ball_limbo_p!=player_num)))
  6014.         {
  6015.             player_comment(&teams[player_num-1]);
  6016.  
  6017.             do_action();
  6018.         }
  6019.     }
  6020. }
  6021.  
  6022. /******************************************************************************
  6023. *****************************************************************************/
  6024.  
  6025. void go_team(int p)
  6026. {
  6027.     if ((p<12 && (team_a_on || p==KP_A)) || (p>=12 && (team_b_on || p==KP_B)))
  6028.     {
  6029.         for (player_num=p; player_num<p+players/2; player_num++)
  6030.         {
  6031.             if (teams[player_num-1].guy_on)
  6032.             {
  6033.  
  6034. // For debugging purposes...
  6035.                 if (player_num==10)
  6036.                 {
  6037.                     player_num++;
  6038.                     player_num--;
  6039.                 }
  6040.  
  6041.                 process_anims(&teams[player_num-1]);
  6042.  
  6043.                 if (!teams[player_num-1].tm_limbo && (!ball_limbo_on || (ball_limbo_on && ball_limbo_p!=player_num)))
  6044.                 {
  6045. // He is NOT bound up in animation!!!
  6046.  
  6047.                     if (!just_thrown)
  6048.                         ball_interact(&teams[player_num-1]);
  6049.  
  6050.                     if (just_scored)
  6051.                         user_controlled=FALSE;
  6052.                     else
  6053.                         user_controlled=teams[player_num-1].control;
  6054.  
  6055.                     if (user_controlled)
  6056.                     {
  6057. // User controls player...
  6058.                         user_plr=player_num;
  6059.  
  6060.                         if (match_mode && match_mode!=THROW_IN_A && match_mode!=THROW_IN_B)
  6061.                         {
  6062.                             if ((user_taker==user_controlled) && (already_there))
  6063.                             {
  6064.                                 user_set_piece(&teams[player_num-1]);
  6065.                                 if (!ball_poss)
  6066.                                     teams[player_num-1].tm_leave=-TRUE;
  6067.                             }
  6068.                             else
  6069.                                 computer_play(player_num);
  6070.                         }
  6071.                         else
  6072.                             user_play(player_num);
  6073.                     }
  6074.                     else
  6075.                         computer_play(player_num);
  6076.  
  6077.                     if (teams[player_num-1].tm_act<=TURN_ACT || teams[player_num-1].tm_act==SAVE_ACT)
  6078.                         add_to_tussle_list(teams[player_num-1].tm_player);
  6079.             
  6080.                     if (!teams[player_num-1].tm_limbo && (!ball_limbo_on || (ball_limbo_on && ball_limbo_p!=player_num)))
  6081.                     {
  6082.                         process_dir(&teams[player_num-1]);
  6083.                     }
  6084.                 }
  6085.             }
  6086.         }
  6087.     }
  6088. }
  6089.  
  6090. /******************************************************************************
  6091. *****************************************************************************/
  6092.  
  6093. void select_all_hlites()
  6094. {
  6095.     char u;
  6096.     short i;
  6097.     char hcol=1;
  6098.     for (short p=0; p<MAX_NET_USERS; p++)
  6099.     {
  6100.         if (users[p].control!=NET_CTRL && users[p].control && users[p].type)
  6101.         {
  6102. // Controlled by a user on this machine...
  6103.             if (users[p].type>0)
  6104.             {
  6105. // Fixed player...
  6106.                 select_hlite(&teams[users[p].type-1],hcol);
  6107.                 hcol++;
  6108.             }
  6109.             else
  6110.             {
  6111. // Auto-user...
  6112.                 if (users[p].type==-1)
  6113.                 {
  6114. // Team A...
  6115.                     for (i=0; i<11; i++)
  6116.                     {
  6117.                         if (teams[i].control==(p+1))
  6118.                         {
  6119. // This user...
  6120.                             select_hlite(&teams[i],hcol);
  6121.                             break;
  6122.                         }
  6123.                     }
  6124.                     hcol++;
  6125.                 }
  6126.                 else
  6127.                 {
  6128. // Team B...
  6129.                     for (i=11; i<22; i++)
  6130.                     {
  6131.                         if (teams[i].control==(p+1))
  6132.                         {
  6133. // This user...
  6134.                             select_hlite(&teams[i],hcol);
  6135.                             break;
  6136.                         }
  6137.                     }
  6138.                     hcol++;
  6139.                 }
  6140.             }
  6141.         }
  6142.     }
  6143. }
  6144.  
  6145. /******************************************************************************
  6146. *****************************************************************************/
  6147.  
  6148. void process_teams()
  6149. {
  6150.  
  6151.     int p;
  6152.  
  6153.     init_tussles();
  6154.  
  6155.     if (frame)
  6156.         p=1;
  6157.     else
  6158.         p=12;
  6159.  
  6160.     go_team(p);
  6161.  
  6162.     if (p==1)
  6163.         p=12;
  6164.     else
  6165.         p=1;
  6166.  
  6167.     go_team(p);
  6168.  
  6169.     if (!dead_ball_cnt && !just_scored)
  6170.         player_tussles();
  6171. }    
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.